Skip to content

fix(no_std): provide f64 polyfills for no_std compatibility#1840

Merged
joshka merged 15 commits intoratatui:mainfrom
j-g00da:no_std/polyfills
May 13, 2025
Merged

fix(no_std): provide f64 polyfills for no_std compatibility#1840
joshka merged 15 commits intoratatui:mainfrom
j-g00da:no_std/polyfills

Conversation

@j-g00da
Copy link
Copy Markdown
Member

@j-g00da j-g00da commented May 10, 2025

Since a lot of float methods are not included in core, I decided to make a simple polyfills crate, so we don't have to conditionally compile every place where these methods are used.

This adds a dependency, that does nothing if we use std. We can either:

  1. Leave as it is, with additional dependency.
  2. If we don't want to add a dependendy by default, we can introduce a std-polyfills (or no-std) feature flag (additional to std). I did something like that here: fix(no_std): final patches needed for no_std #1833.
    This has one drawback - we have to use either std or std-polyfills feature flag or the library won't compile.
    To make it easier on the user, we can add a check in lib.rs that emitts compiler error "either std or std-polyfills feature flag must be enabled" in such cases.
  3. I can try to make the float-polyfills crate lighter, not depending on libm (or gate libm behind feature flag).

Let me know what you think and if you have some other ideas for this.

Related: rust-lang/rust#137578

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

3 participants