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

no_std support #24

Merged
merged 5 commits into from
Oct 2, 2021
Merged

no_std support #24

merged 5 commits into from
Oct 2, 2021

Conversation

geeklint
Copy link
Contributor

@geeklint geeklint commented Oct 1, 2021

This implementation has LCell and QCell (fast_new only) fully supported on no_std.
If you enable the alloc feature, you gain QCell::new.
TCell and TLCell are supported only under the std feature.

This shouldn't touch any functional code, just modify some imports, add feature gates, and tweak documentation.

Tests for items that aren't available are not enabled. This excludes most of the QCell tests when the alloc feature is disabled, as they rely on QCell::new. Here are the my test counts:

  • cargo test --no-default-features: 8 tests, 25 doc-tests.
  • cargo test --no-default-features --features "alloc": 13 doc-tests, 45 doc-tests.
  • cargo test and cargo test --no-default-features --features "std": 28 tests, 92 doc-tests.

There is one doc-test in lib.rs that I had to add the std feature-gate to, this makes it look a little funny in the source code but the resulting HTML documentation is unchanged.

I just shuffled some things around in assertions.rs to group the feature-gated ones, but feel free to double check that I didn't accidentally delete any.

@uazu
Copy link
Owner

uazu commented Oct 2, 2021

This all looks fine, thanks. The feature documentation is a nice touch.

Before I do the next release, I'll go over the docs again and maybe tweak a few things. The new and fast_new calls are likely to be much closer in speed than they were previously. However fast_new is still important for pure no_std.

Are you planning any more PRs? This is just to decide when to do the next release.

Also, do you have plans to use qcell in a no_std project? This is just to understand how it might be used. (For example, if there is no alloc, then Rc is out.)

@uazu uazu merged commit 52d0210 into uazu:master Oct 2, 2021
@geeklint
Copy link
Contributor Author

geeklint commented Oct 2, 2021

I have a couple other ideas I might prototype over the weekend and suggest.

I'm intending on making qcell an optional dependancy of one of my crates, as a pluggable alternative to RefCell. It will unconditionally depend on alloc (for precisely Rc).

@uazu
Copy link
Owner

uazu commented Oct 2, 2021

Okay, thanks! If you want to thrash out any ideas, you could raise an issue to discuss them, or add to the discussion on no_std if it is related.

@SoniEx2 SoniEx2 mentioned this pull request Jan 25, 2022
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.

None yet

2 participants