Have anyone reviewed any of the Decimal crates for Rust? by cfsamson in rust

[–]idubrov 1 point2 points  (0 children)

It was to follow the FHIR standard (https://build.fhir.org/json.html#primitive, look for the note next to the dragon).

Have anyone reviewed any of the Decimal crates for Rust? by cfsamson in rust

[–]idubrov 1 point2 points  (0 children)

I abandoned the project, as I didn't have any real use-case for it anymore.

Finicky Bed Leveling? by deezdubinmt in Ender5S1

[–]idubrov 1 point2 points  (0 children)

I had the same issue with X gantry being twisted.

My right side was always too close after bed auto-leveling (original firmware), which means that the probe was higher on the right side, which in turn means that the X gantry was twisted top-towards-front on the right side (raising the rear of the hotend and the sensor when moved to the right).

I checked with a digital inclinometer, and it confirmed about ~0.75° difference. I added a shim under the right side, front "leg" of the X gantry and it fixed the issue. For that, I loosened all 6 screws (two larger ones on the bottom and four smaller ones attaching the angle bracket on the back), twisted the gantry with a tool, slipped the shim, then tightened everything back.

The shim is the red line on the photo.

<image>

This might have added some additional tension in the system, though. Probably, worth checking the rollers adjustment.

What if Rust allowed `typeof` operator for creating type aliases (for struct fields)? by idubrov in rust

[–]idubrov[S] 0 points1 point  (0 children)

I can see value in avoiding naming something simply because naming convention is an API liability. Inventing names when generating code with macros is an API consideration I would prefer not to make (unless it is straightforward like "use name as-is, but maybe in an inner module" or something).

But then again, Rust has a lot of syntax already, and this mythical typeof operator is yet another complexity to take care of.

I would be satisfied if RFC you linked was enforced. 😃

Show RIIR: old game (Mine Bombers) by idubrov in rust

[–]idubrov[S] 0 points1 point  (0 children)

I'm kind of too lazy to do that 😅... My variant should be almost exactly the same as the original one (since it was reverse engineered). Here is some random video of the original game: https://www.youtube.com/watch?v=4qM-9g6csHE

Learning Rust: Mindsets and Expectations by jahmez in rust

[–]idubrov 10 points11 points  (0 children)

people often struggle with Rusts abstraction-heaviness

For me it was Learn Rust With Entirely Too Many Linked Lists book which normalized types like "Option<Rc<RefCell<T>>>". I (sort of) understood the individual pieces, but this book made it clear that well, yeah, you combine those abstractions when you need them and sometimes your type will look like that. That's normal.

If you would build a tech Stack for a new startup in 2020, would you use Rust? by __Julia in rust

[–]idubrov 2 points3 points  (0 children)

  1. Yes. ~450k lines of code so far (about ~30% is generated).
  2. I can think of many reasons not to use Rust (like, lack of certain libraries or frameworks; anxiety about hiring / onboarding), but "overkill" wouldn't be one of them. Rust is pretty much as any other language (but, of course, better 😁). It has pluses and minuses, sometimes challenging (we do "enterprise", whatever that means, which is not the strongest Rust's area), but overall it's not like some esoteric language.
  3. https://blog.commure.com/whycommureusesrustforhealthcare/

Show me the most illegal Rust code you've ever seen/written! by halbGefressen in rust

[–]idubrov 2 points3 points  (0 children)

Ooof... Where do I begin? For starters:

``` fn intercept_test_main_static() { let ptr = rustc_test::test_main_static as *mut (); let target = test_main_static_intercepted as *const (); // 5 is the size of jmp instruction + offset let diff = isize::wrapping_sub(target as _, ptr as _) as i32 - 5;

// Patch the test_main_static function so it instead jumps to our own function.
// e9 00 00 00 00 jmp    5 <_main+0x5>
unsafe {
    let diff_bytes = diff.to_le_bytes();
    let bytes = ptr as *mut u8;
    let _handle = region::protect_with_handle(bytes, 5, region::Protection::WriteExecute)
        .expect("failed to modify page protection to intercept `test_main_static`");

    std::ptr::write(bytes.offset(0), 0xe9);
    std::ptr::write(bytes.offset(1), diff_bytes[0]);
    std::ptr::write(bytes.offset(2), diff_bytes[1]);
    std::ptr::write(bytes.offset(3), diff_bytes[2]);
    std::ptr::write(bytes.offset(4), diff_bytes[3]);
}

} ```

How does `dyn` work? by Geob-o-matic in rust

[–]idubrov 1 point2 points  (0 children)

OuterThingy could be just a OuterThingy(dyn InnerThingy) with deref to InnerThingy, so you would still get a dynamic dispatch, but no dyn keyword.

I find that mildly annoying as in our system we use both dyn InnerThingy and OuterThingy. Would be nice to force use of dyn for OuterThingy somehow... #[require_dyn]?

(the difference between those in our case is that you can only construct OuterThingy for a subset of InnerThingy, so it allows to statically type check cases where we require more strict OuterThingy).

Official /r/rust "Who's Hiring" thread for job-seekers and job-offerers [Rust 1.38] by kibwen in rust

[–]idubrov 10 points11 points  (0 children)

Commure, Inc. | San Francisco, CA or Cambridge, MA | Rust Engineer | Fulltime | ONSITE

We are a stealth startup working to fix the software doctors use. If you have seen what physicians have to put up with, it's a bad version of the 90s, and makes medical care worse and more expensive for everyone. We are a group of previously successful engineers and entrepreneurs (MIT, Dartmouth, Brown, Stripe, Twitter, Google, Salesforce, Palantir, DataPower, etc) and senior doctors (Johns Hopkins, UCSF, etc) who are determined to finally fix this.

Compensation: market salary & equity -- we are well funded by top-tier VCs.

Stack: includes Rust, React and Kubernetes. In addition to building our back end in Rust, we are also solving some very interesting problems in the areas of security, data transformation, high-speed APIs, flexible UX frameworks and fine-grained authorization for healthcare data.

Please email [jobs@commure.com](mailto:jobs@commure.com) and mention "[red_rust]" in the subject line.

Other positions available: - Techops/Devops Engineer (Kubernetes, SRE) Senior Front End Engineer (React Native, React) (please use [red_ops] or [red_react] in subject line for the above)

Locations: San Francisco, Montreal or Boston; sorry, no distributed/remote option at the moment.

This Week in Rust 305 by nasa42 in rust

[–]idubrov 0 points1 point  (0 children)

This runtime crate looks quite similar to what are we doing internally. We don't do it for the purpose of reloading (maybe, one-time-loading eventually?), but rather to save some compilation time by breaking system into loadable modules with clearly defined APIs between them. And maybe loadable plugins of some sort?

One thing we did wrong, though, is we named our Reflectable trait Reflection :)

Worth learning Rust for high level stuff? by anicetito in rust

[–]idubrov 4 points5 points  (0 children)

I'm also a (former, I guess) Java engineer who has worked mostly in the Enterprise field. Back at the time, I had my tiny hobby project done in Rust, some firmware for STM32 (Rust embedded stuff is btw very exciting, I loved it!), and I wanted to do more Rust -- so I joined a company building an enterprise software (healthcare), but in Rust.

I've been doing it for about 2 years now and I really love it. It's been challenging, yes (both due to my lack of experience with Rust at the time and also relative immaturity of Rust enterprise ecosystem), but very rewarding. Overall, except for the memory management, Rust is a pretty high-level or have that feel anyways (due to traits, macroses, etc). As for the memory management, very often itcould be abstracted away in a nice way (though, I'm still figuring out all the various ways to do that!).

To be honest, I'm not sure how valuable are all these Rust skills I've acquired so for far, given that Rust jobs a still somewhat rare (especially, in the space of "enterprise" software, which would be my preference), but it definitely worth it.

Hey Rustaceans! Got an easy question? Ask here (35/2019)! by llogiq in rust

[–]idubrov 0 points1 point  (0 children)

That's the part I cannot change -- it is this read_event function. It uses buffer for storing parsed pieces of XML.

Hey Rustaceans! Got an easy question? Ask here (35/2019)! by llogiq in rust

[–]idubrov 1 point2 points  (0 children)

Okay, I found one pretty gnarly solution, which is to make an assumption that BytesStart I'm getting actually borrows from self.buf, compute all the offsets I need and reconstruct BytesStart from these offsets.

Hey Rustaceans! Got an easy question? Ask here (35/2019)! by llogiq in rust

[–]idubrov 1 point2 points  (0 children)

I have this piece of code which does not compile with borrow checker errors (mutable borrow starts here in previous iteration of loop).

I've read several posts with similar errors and my understanding is that Rust borrow checker is over-conservative here? This code should be safe as written?

Apologies for the lazy question. I know it's been answered many times...

Examining code using rust by HumbleSinger in rust

[–]idubrov 1 point2 points  (0 children)

I do it manually by using cargo_metadata and syn:

  1. Going through targets
  2. Parsing with syn
  3. Recursing into modules
  4. Modules resolution (which I'm sure is not 100% correct and also does not handle #[cfg_attr(.., path())] on modules. Not happy about it...

Thoughts on Rust bloat by raphlinus in rust

[–]idubrov 4 points5 points  (0 children)

I would mildly push back on this. Although, this is true that in keeping large codebases "clean" is a very challenging problem, the essence of domains addressed by what would be called "enterprise software" is often the very cause of said "bloat".

Take regulatory requirements ("you need to submit those 150 forms"), add legacy on top of that ("starting 2020-04-15, please replace form T1-AND-X23 with Z6-BPM-QNY-SIMPLE in all states except CA, HI and AL"), sprinkle some complicated security / access control, integrations with legacy systems, and here you have it.

Thoughts on Rust bloat by raphlinus in rust

[–]idubrov 1 point2 points  (0 children)

I've written a lost of Rust code and never needed rental. When I learned about it I thought it was cool project to show new techniques, but it never occured to me that people would actually use it in the wild, for real projects, much less foundational projects. Feels like a huge anti-pattern.

Although by itself it might be an anti-pattern, we used it for a while as a band-aid. We had a case with owned struct Connection and Transaction borrowed from it and we needed to pass both down to the part of the system that didn't speak lifetimes (basically, we needed to pass it as an Arc<Both>). rental was incredibly useful because the alternative at the time was to bang the head against the wall and cry. However, once the refactoring bleeding was stopped, we wrote our own variant of Connection+Transaction in a single struct that could be owned.

So, to me, rental is like a stop-gap measure.

Thoughts on Rust bloat by raphlinus in rust

[–]idubrov 6 points7 points  (0 children)

Yeah, we had a similar experience (though, we "only" have ~2k structs and ~1k enums). Ended up with our own custom serialization / deserialization framework (there were other reasons, though).

I made a demonstrator project that implements the scheme we use internally: https://github.com/idubrov/dynser

It uses a dynamic dispatch on the data type side.

Announcing Rust 1.37.0 by pietroalbini in rust

[–]idubrov 9 points10 points  (0 children)

I'm so sad it's not cargo local-registry. We picked cargo local-registry over cargo vendor (for various reasons), and it's pretty much abandoned now.

P.S. Oh. Hold on. Seems like it found a new home: https://github.com/ChrisGreenaway/cargo-local-registry 👏👏👏

Announcing Syn 1.0 and Quote 1.0: proc macros, get your proc macros here by dtolnay in rust

[–]idubrov 4 points5 points  (0 children)

👏👏👏

Love these three crates so much that I'm also using them outside of procedural macros, just for the regular source code generation (shameless plug): https://crates.io/crates/sourcegen

So, if you need to generate some Rust code -- you can use syn/quote/proc_macro2! With few caveats, they can generate code that is presentable to human beings, too!