frunk icon indicating copy to clipboard operation
frunk copied to clipboard

rework #![no_std] support, switch on `alloc`

Open mammothbane opened this issue 6 months ago • 2 comments

Finally got around to change I brought up in #220. See also #233.

Most of the uses of std in the crate are of Vec, String, and Box, which are in alloc, which is available on #![no_std] via extern crate alloc;. This commit adjusts these uses to use alloc directly and adds an alloc feature flag to control them. The notable exceptions still requiring a std flag are HashMap and HashSet (I'm working on a separate change to add BTree{Map,Set} support for #![no_std] envs). frunk_core no longer needs a std flag: it has been marked deprecated with a comment.

The reimport of core as std (see #220 for historical explanation) is converted to direct usage of core everywhere.

Removed #[cfg(feature = "std")] condition from frunk_laws and made it depend on frunk/std -- it depends on quickcheck, which requires std.

Added #[cfg(test)] extern crate std; to #![no_std] crates, as std is required to run the libtest harness.

Tested against all the combinations of feature flags I could think of. Successfully compiles into a #![no_std] embedded project with alloc enabled.

mammothbane avatar Jul 30 '24 12:07 mammothbane