Cargo Features
no-std-compat2 has no features set by default.
[dependencies]
no-std-compat2 = { version = "0.4.5", features = ["alloc", "std", "unstable", "compat_hash", "compat_sync", "compat_macros", "compat_cstr", "compat_osraw", "compat_path", "compat_guard_unwrap"] }
- alloc
-
This feature pulls in
alloc
and exposes it in all the usual locations. I.estd::collection
gets mapped toalloc::collections
and all the allocation stuff is added to the prelude. - std
-
This feature pulls in the entire standard library and overrides all other features. This effectively bypasses this crate completely. This is here to avoid needing feature gates: Just forward your optional
std
feature to here, we handle the rest.Affects
no-std-compat2::prelude
… - unstable
-
This feature also re-exports all unstable modules, which isn't possible to do unless you compile with nightly. Unless you need an unstable module, this crate supports stable rust.
- compat_hash = hashbrown
-
This will sadly also add hashbrown even if overriden by std. Cargo does not seem to provide any cfg(compat_hash && !std) functionality. Luckily, hashbrown is really small.
This pulls in hashbrown (which is not HashDoS-resistant!! but #![no_std]). The point is so you can keep using the standard, safe, HashMap for those who have the standard library, and fall back to a less ideal alternative for those who do not. Be advised, however, that this used in a public function signature could be confusing and should perhaps be avoided. But that is up to you!
- compat_sync = spin
-
This pulls in spin and provides replacements for several things used in
std::sync
. - compat_macros
-
This feature adds dummy
println
,eprintln
,dbg
, etc. implementations that do absolutely nothing. The point is that any debug functions or other loggings that are not required for the library to function, just stay silent inno_std
. - compat_cstr = cstr_core
-
Enable CStr
- compat_osraw = libc
-
Enable std::os::raw
- compat_path = unix_path
-
Enable std::path
- compat_guard_unwrap
-
.
Affects
generated::compat_guard_unwrap
…
Features from optional dependencies
In crates that don't use the dep:
syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.