feat: Add no_std support by refactoring imports to use core and alloc#149
feat: Add no_std support by refactoring imports to use core and alloc#149stevefan1999-personal wants to merge 3 commits into
core and alloc#149Conversation
|
In general I'm in favor of making things less std-dependent, but I'm not sure it's worth the extra dependencies. Can't we just disable things that need std? Like, locking is only used for
No, this is definitely a breaking change, because |
Hmm, that would mean we need to make So now the imminent problem is that I missed the From... |
jplatte
left a comment
There was a problem hiding this comment.
@stevefan1999-personal do you actually have a use case for this or did you just instruct the slop machine to do this because you think you're "helping" (whom?)?
| #[macro_export] | ||
| macro_rules! get_in { | ||
| ($target:expr, $path:expr => $($tail:tt) => * ) => {{ | ||
| ($target:expr_2021, $path:expr_2021 => $($tail:tt) => * ) => {{ |
There was a problem hiding this comment.
Excuse the language but this is such a stupid random change completely unrelated the the purpose of this PR. It just makes the diff longer, for n reason.
There was a problem hiding this comment.
Well because you're not even wrong -- I didn't even use LLM for the code here and just ran ordinary Clippy passes manually with some deny hints so that I can insert alloc crates.
It turns out I shouldn't change the Rust edition altogether because Clippy will fix that if you added --fix to it. I think it was a last moment that I thought upgrading to 2024 was worth it, then I backtracked on it, leaving those on the diff.
The PR description was indeed written by LLM because I want it to have content and at least have some level of attention. But your assumption that all of its code is written in LLM is not exactly right.
And still, I really hate writing those PR descriptions. Yet you can't just leave it empty.
I'm actually using this for a control flow graph, that I want it to work in no_std, although there is some...monomorphization issue |
Description
This PR adds
no_stdcompatibility toimblby refactoring all imports fromstdto theircoreandallocequivalents.Summary of Changes
core::andalloc::instead ofstd::where applicablehashbrown::HashSetinstead ofstd::collections::HashSet, enabling tests to run with--no-default-featuresCargo.tomlto supportno_stdconfigurationsFiles Changed
hash/map.rs,hash/set.rs,ord/map.rs,ord/set.rs,vector/mod.rs,vector/focus.rsnodes/btree.rs,nodes/hamt.rs,nodes/rrb.rslib.rs,iter.rs,sort.rs,sync.rs,util.rsser.rs,proptest.rs,quickcheck.rs,arbitrary.rs,bincode.rstests/hashset.rs,tests/ordset.rs,tests/vector.rs,test.rs,fakepool.rsCargo.toml,Cargo.lockKey Technical Changes
std::imports that have equivalents incore::oralloc::have been updatedhashbrown::HashSetas the reference implementation, which is available in bothstdandno_stdenvironmentsstdcode: Code that requiresstd(likestd::collections::HashSetconversions) remains behind#[cfg(feature = "std")]Testing
All 122 tests pass in both configurations:
cargo nextest run(with default features)cargo nextest run --no-default-featuresBreaking Changes
Practically none. The
stdfeature remains enabled by default, maintaining full backwards compatibility.However, all the hash map implementation has been replaced by
hashbrown, whilestdalso useshashbrown, this is still an external dependency for us.There are also some other stuff that was not available under
no_stdenvironment, such asMutexandDefaultState, those are also being replaced with generic implementations that is portable.