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

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

Merged
merged 3 commits into from
Aug 31, 2024

Conversation

mammothbane
Copy link
Contributor

@mammothbane mammothbane commented Jul 30, 2024

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.

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]`
platforms 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 removed.

The reimport of `core` as `std` (see lloydmeta#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 working against all the combinations of feature flags I could
think of.
@lloydmeta
Copy link
Owner

Thanks for this; I'll review more once I get a chance, but IIUC this should probably result in at least a minor version bump right?

@mammothbane
Copy link
Contributor Author

mammothbane commented Jul 31, 2024

Yeah, everything other than removing the frunk_core/std should be minor — everything's compatible. Removing frunk_core/std is major, but I can add have added it back and marked as deprecated.

Copy link
Owner

@lloydmeta lloydmeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for this. I'll keep this open for now just to make sure I don't miss it; planning to cut a new release by end of month.

@lloydmeta lloydmeta merged commit 93c4db7 into lloydmeta:master Aug 31, 2024
13 checks passed
@lloydmeta
Copy link
Owner

Thanks for this. Just cut a new release for this.

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.

2 participants