-
Notifications
You must be signed in to change notification settings - Fork 35
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
lib: add support for no_std builds #68
Conversation
Thank you for your PR! |
BTW, I fixed clippy warnings in #69. So, please merge the master branch to fix CI lint failures. |
nice |
This PR basically seems good. However, this change always adds extra dependencies |
Thanks for the review.
That makes sense to me. Wasn't sure if following the default The two fixup commits implement the changes you requested, and remove the default If you like the changes, I'll squash them into the original commit. |
Thank you for the changes! LGTM 👍
I will merge this PR once you do that. |
Introduce a new, default `std` feature to the library, and conditionally use structures and traits from `no_std` compatible libraries. Existing `std` users can continue using the library with no changes. `no_std` users can import the library using `default_features = false`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
That is definitely the better pattern to follow - cargo features are intended to be additive, since if multiple libraries depend on different features in a library, both features are enabled . A Please consider redoing this PR the way most of the community follows and Cargo intends. This PR also doesn't fix
The way to alleviate this is to make |
@kupiakos Thank you for your comment.
Make sense. Are you interested in creating a PR for this change? |
I can take a look sometime this next week. Which option of these would you prefer @sile ?
|
Great!
I don't have a strong opinion on which one is the better choice at this point. |
Yeah, this is how the original PR was. The conversion isn't too involved (basically a few global Let me know if you would like me to make the PR, or if you want to. I'm good with either, and appreciate your review.
The library still technically builds, but yes, I missed these dependencies bringing in
Right, I missed those dependencies you mentioned. Good catch 👍 |
This also: - fixes the `no_std` not being enabled due to a swapped `cfg_attr`. - tests this builds with a `#![no_std]` binary. - A lot of the cfg's have been removed due to being unneeded. - adds a new dependency - updates the version to 2.0 - adds a ci command to to use cargo-no-std to check no-std Some notes on changes from sile#68: Everything in `core` is a subset of things in `std`. `core` is available in `std` environments, so if you're building a `no_std`-compatible library, it's best to import things that don't _require_ `std` from `core. core2 is also meant to be used as a `no_std` polyfill with its `std` feature. That is, you can reference `core2::io`, and if the `std` feature is enabled, it actually references `std::io`.
@@ -2,8 +2,19 @@ | |||
//! | |||
//! LZ77 is a compression algorithm used in [DEFLATE](https://tools.ietf.org/html/rfc1951). | |||
#![warn(missing_docs)] | |||
#![cfg_attr(no_std, feature = "no_std")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be #![cfg_attr(feature = "no_std", no_std)]
- I don't believe the library was actually building as no_std
.
This also: - fixes the `no_std` not being enabled due to a swapped `cfg_attr`. - tests this builds with a `#![no_std]` binary. - A lot of the cfg's have been removed due to being unneeded. - adds a new dependency - updates the version to 2.0 - adds a ci command to to use cargo-no-std to check no-std Some notes on changes from sile#68: Everything in `core` is a subset of things in `std`. `core` is available in `std` environments, so if you're building a `no_std`-compatible library, it's best to import things that don't _require_ `std` from `core. core2 is also meant to be used as a `no_std` polyfill with its `std` feature. That is, you can reference `core2::io`, and if the `std` feature is enabled, it actually references `std::io`.
This also: - fixes the `no_std` not being enabled due to a swapped `cfg_attr`. - tests this builds with a `#![no_std]` binary. - A lot of the cfg's have been removed due to being unneeded. - adds a new dependency - updates the version to 2.0 - adds a ci command to to use cargo-no-std to check no-std Some notes on changes from sile#68: Everything in `core` is a subset of things in `std`. `core` is available in `std` environments, so if you're building a `no_std`-compatible library, it's best to import things that don't _require_ `std` from `core. core2 is also meant to be used as a `no_std` polyfill with its `std` feature. That is, you can reference `core2::io`, and if the `std` feature is enabled, it actually references `std::io`.
Introduce a new, default
std
feature to the library, and conditionally use structures and traits fromno_std
compatible libraries.Existing
std
users can continue using the library with no changes.no_std
users can import the library usingdefault_features = false
.Changes were testing by running the test suite using the
std
andno_std
configurations: