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

Add #![no_std] support #314

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

FreezyLemon
Copy link
Contributor

@FreezyLemon FreezyLemon commented Dec 6, 2024

Closes #165.

Standard library types that exist in libcore are usually just reexported through std::, so changing from e.g. std::f64 to core::f64 results in no change in behavior.

There are a few things to note:

  • All nalgebra-dependent features require std at the moment. I'm not sure OVector/OMatrix can be used without std because of Dyn, but nalgebra does support no_std and SVector/SMatrix should work without libstd. Out of scope here though.
  • Some other features also require libstd, so they're disabled in no_std. E.g. all functions that have a Vec parameter/return type like OrderStatistics::ranks.
  • core::error::Error exists, but was only recently stabilized in 1.81.0. I decided to not use this yet and instead not implement the Error trait in no_std.
  • Tests have worse error messages in no_std. I don't know how to this type of string formatting without String, so I just dropped it. Dev machines should usually have it available anyways.

- `std::fmt` -> `core::fmt`
- `std::f64` -> `core::f64`
- misc.
- Gate some API that needs `Vec` behind the "std" feature
- Add no_std stub for `make_param_text`
`core::error` needs an MSRV of 1.81,
which is a bit too new for this crate
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 41.09589% with 43 lines in your changes missing coverage. Please review.

Project coverage is 93.81%. Comparing base (a8fe65c) to head (2553589).

Files with missing lines Patch % Lines
src/distribution/internal.rs 0.00% 5 Missing ⚠️
src/generate.rs 16.66% 5 Missing ⚠️
src/distribution/bernoulli.rs 0.00% 1 Missing ⚠️
src/distribution/beta.rs 0.00% 1 Missing ⚠️
src/distribution/binomial.rs 0.00% 1 Missing ⚠️
src/distribution/categorical.rs 0.00% 1 Missing ⚠️
src/distribution/cauchy.rs 0.00% 1 Missing ⚠️
src/distribution/chi.rs 0.00% 1 Missing ⚠️
src/distribution/chi_squared.rs 0.00% 1 Missing ⚠️
src/distribution/dirac.rs 0.00% 1 Missing ⚠️
... and 25 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #314      +/-   ##
==========================================
- Coverage   93.81%   93.81%   -0.01%     
==========================================
  Files          53       53              
  Lines       11996    12005       +9     
==========================================
+ Hits        11254    11262       +8     
- Misses        742      743       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

no_std support
1 participant