-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No std (extends 2018 edition) #18
Conversation
Okay. On 2015 edition the way to do no_std is to add a The alloc import isn't 2018 idiomatic because it does If you don't want the 2018 edition yet, I can take another attempt at 2015 no_std, but that effort would be undone when you accept 2018. |
@@ -2,6 +2,7 @@ | |||
#![doc(html_root_url = "https://docs.rs/slotmap/0.3.0")] | |||
#![crate_name = "slotmap"] | |||
#![cfg_attr(feature = "unstable", feature(untagged_unions))] | |||
#![cfg_attr(not(feature = "std"), feature(alloc))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: I had no_std
last night, but that wasn't cargo idiomatic as cargo features are additive, so std
is more correct (and common).
pub mod sparse_secondary; | ||
pub use sparse_secondary::SparseSecondaryMap; | ||
#[cfg(feature = "std")] | ||
pub use crate::sparse_secondary::SparseSecondaryMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashMap
currently requires std
because it assumes the default RandomState
, which relies on OSRng. rust-lang/rust#56192
(Not 100% sure git is smart enough to merge this without duplicating the |
Since we support I don't know exactly how this would end up working. In particular the last section about We also need to replace |
@orlp Oh. Quick fix. Edit: turns out both |
@orlp Maybe |
@orlp Regarding no-std tests. We aren't really testing no-std tests anyway. The testing infrastructure for no-std is (1) does it build? and (2) does it work under no-std environments? I might tell you the latter soon as I'm working on https://robigalia.org but I'm not ready to test my code using slotmap on that yet. |
@orlp Just did a quick pass over serde code. |
Ugh. Problem. |
Aren't we missing
I was worried about that too... Also |
@orlp Wow. Yes... Seems that with all the rebasing and reimplementing ... I missed a few things. o.0 Fixed.... |
It seems that there is no solution: https://www.reddit.com/r/rust/comments/78pn60/enabling_feature_of_optional_dependency/. Perhaps no std support is just a bit too infantile in Rust to start supporting it. |
|
Yikes. |
@orlp Fixed #N! |
@orlp Including a compile time lint. ;) |
Use feature |
I don't like that solution because now regular users need to specify
With an error if |
@orlp Not quite. You can't have a feature and dependency by the same name. But you could rename the serde dependency internally. |
@orlp Also, not all no-std users will want alloc. |
If a no-std user doesn't want alloc they can't use |
But I think it is safe to say that slotmap does depend on alloc as it doesn't at least currently use an array or GenericArray anyway... |
@orlp For now we assume alloc. But I might send in another time, a PR for a |
However, my solution then runs in the opposite issue, in that it relies on Honestly, all of this is just too big of a headache right now. I think I'd rather wait a couple more months to see what has changed in support of |
@orlp Okay. Sorry to hear that. I can wait to merge this in. I know I'll need it eventually, but I don't use serde and will be fine with my fork. :) |
Thanks for your contributions regardless. It's not your fault no-std is kind of a mess right now :) |
With all the changes in |
Messing with the imports for 2015 edition is more annoying for no_std and my attempts failed. Sure it can be done, but it isn't worth it as there is no reason against using the 2018 edition.
Blocking on #16.