4 ms·
Damn, I've been doing a bunch of exploring of this exact topic over the past week. This would have saved me a bunch of time. Unlucky for me it wasn't submitted
by xxpor 5y ago
Damn, I've been doing a bunch of exploring of this exact topic over the past week. This would have saved me a bunch of time. Unlucky for me it wasn't submitted last Sunday!
One thing that's killed me a bit is the core::/std:: split, when the core:: versions have the exact same semantics, or perhaps are equivalent for the things that they do implement (for example, the core version might be missing the serde parts, but is otherwise the same). There's a few crates I tried out that wouldn't compile with no_std, but with a simple text substitution, would work. I'm sure there's a million edge cases I'm not aware of, but if cargo or rustc could provide an option to just sub in the core version, that'd be really nice.
- eska 5y agoI assume one could send a patch to those crates that defines “use core::” instead of “use std::” by using the compile time config directive to check whether the std is enabled?
- xxpor 5y agoOh yes, and I've started preparing those patches. It's just a bit of a bummer to have the churn when you're just starting out and iterating through ideas.
- hkalbasi 5y agoIsn't "use core::" enough, without compile time config directive?
- saghm 5y agoIf you disable stuff with `cfg`, you have the ability to give cleaner error outputs. When designing a library to allow choosing between one of two dependencies for an async runtime, I conditionally compiled out all of the crate except for one of two invocations of the `compile_error!` macro (https://doc.rust-lang.org/std/macro.compile_error.html https://doc.rust-lang.org/std/macro.compile_error.html) if either both or neither of the dependencies were enabled, which I think made the experience for users of the library much better compared to having to figure out what was going on from pages and pages of "not found" or "already defined here" errors.
- nynx 5y agoYeah, std is actually just stuff re-exported from core + some more stuff.