uazu / qcell

Statically-checked alternatives to RefCell and RwLock
Apache License 2.0
356 stars 22 forks source link

no_std support #24

Closed geeklint closed 2 years ago

geeklint commented 2 years ago

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:

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 commented 2 years ago

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.)

geeklint commented 2 years ago

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 commented 2 years ago

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.