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

In no_std context, use no_std num-traits. #59

Merged
merged 1 commit into from
Mar 13, 2019
Merged

In no_std context, use no_std num-traits. #59

merged 1 commit into from
Mar 13, 2019

Conversation

cbiffle
Copy link
Contributor

@cbiffle cbiffle commented Mar 8, 2019

This crate was not actually no_std compatible because it (1) used
num-traits with the std feature, and (2) relied on the Float trait,
which is unavailable in no_std.

I have altered it to rely on FloatCore instead and passed the feature
flag through to the dependency.

Had to bump the version of num-traits required, because FloatCore only
appeared in 0.2.1.

@cbiffle
Copy link
Contributor Author

cbiffle commented Mar 8, 2019

Incidentally, it looks like you're trying to test the no_std build on Travis. Excellent!

However, Cargo does not transitively enforce no_std-ness. Simply clearing the std feature at the root package is not enough.

The safest way to avoid this is to build for a target triple with the OS component of none. Such targets don't ship with libstd and so the build will fail if you transitively depend on it. (This is how I noticed the issue.)

I've checked this target, which might be an option:

cargo build --target thumbv7em-none-eabihf --no-default-features

You won't be able to run (or build) your tests on such a target, as the test framework doesn't support no_std. (You're currently able to test no_std only because of the no-enforcement issue I mentioned above.)

This crate was not actually no_std compatible because it (1) used
num-traits with the `std` feature, and (2) relied on the `Float` trait,
which is unavailable in no_std.

I have altered it to rely on `FloatCore` instead and passed the feature
flag through to the dependency.

Had to bump the version of num-traits required, because FloatCore only
appeared in 0.2.1.
@mbrubeck mbrubeck merged commit 9aa400f into reem:master Mar 13, 2019
@mbrubeck
Copy link
Collaborator

Thanks!

mbrubeck added a commit that referenced this pull request Mar 13, 2019
* Implement `FromStr` (#53)
* Internal refactoring (#55)
* Fix for `no_std` builds (#59)
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