Skip to content
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

Support building without libstd #106

Merged
merged 7 commits into from
Oct 13, 2019
Merged

Support building without libstd #106

merged 7 commits into from
Oct 13, 2019

Conversation

bluss
Copy link
Member

@bluss bluss commented Oct 1, 2019

Recast version of #95 by @leo60228

  1. Continue supporting current Rust versions in the default configuration
  2. On targets where std is missing, compile as no_std using the feature detection leo added in autocfg (Requires Rust 1.36)
  3. There's no feature flag for this, because it's not needed (negative feature flags being awkward), and because it could be considered to be a breaking change
  4. Constructor new etc is not available without std — one has to use the others like with_hasher or default. The indexmap! macros depend on these as well, and require std too.

This approach, in particular (3) is novel, and thus it is out for wider requests for comments.

A no-std indexmap has been requested by petgraph.

Fixes #94
Closes #95
Closes #92

@bluss
Copy link
Member Author

bluss commented Oct 1, 2019

I also looked at autocfg to figure out how to test this. ⚙️

I have a worry that other "no_std" using crates are going to be disappointed in this (3) scheme, when they can't test this with crate features as we normally do.

I still lean towards this being the morally right way to handle no_std; we build without it because it is not available.

I'm looking for a simpler no-std hasher than ahash (since it depends on a lot of stuff).

@bluss bluss changed the title Support building without libstd Draft: Support building without libstd Oct 2, 2019
@cuviper
Copy link
Member

cuviper commented Oct 3, 2019

The main hazard I see in leaving this implicit is that users could end up depending on std-required API (like IndexMap::new) without realizing it. I guess it's up to them to try a true no_std target if they really need that. Plus this kind of failure can also happen with unified features -- if something else in your dependency tree enables a feature, you can also use it without declaring so.

But I am in the camp that losing std with default-features = false is a breaking change, so this auto-detection is really the only way around that.

I'm looking for a simpler no-std hasher than ahash (since it depends on a lot of stuff).

Maybe twox-hash? Or since it's just for testing, you could add a private copy of fnv / fxhash.

bluss added 2 commits October 4, 2019 20:32
Uses shepmaster's hash crate for testing, it's simple and no-std, tip by cuviper.
(Due to using the ::with_capacity method.)
@bluss bluss changed the title Draft: Support building without libstd Support building without libstd Oct 13, 2019
@bluss
Copy link
Member Author

bluss commented Oct 13, 2019

Thanks for implementing @leo60228 and thanks @cuviper for guiding the implementation.

I'll aim to release this in Indexmap 1.3 since it's a new feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make this crate no_std
2 participants