-
Notifications
You must be signed in to change notification settings - Fork 17
Add no_std
support
#24
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
Conversation
No features required as crate only needs `core` and `alloc`
1.34 does not have access to `alloc`, 1.36 does
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.
One observation that this rework brought to attention: the way the data is shaped, I don't think any of the n.{b,g,r}
in the network can actually be NaN
and then neither can be their differences. I was initially concerned about performance (and still, might be nice to check with some examples) but really it may be possible to specialize some of the standard functions around the non-NaN property and win performance in that way if the optimizer can not proof the same already.
I experimented in Godbolt and confirmed that a large number of |
I've replaced the implementations in Doing so removes the performance boost that comes from |
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.
Looks quite polished to me now. @fintelia I'd say we go for a release under 1.*
and at worst yank that if there are too many people still stuck under 1.34
as that would be highly unexpected to me.
Checking crates.io, there are only 5 listed dependents on All other dependents either list an MSRV above 1.34, or are on edition 2021/2024 (and thus incompatible with Rust 1.34). As such, I think the bump from Rust 1.34 to 1.36 should have zero impact on the crates.io ecosystem. If someone is affected by this, it can be easily mitigated by adding the following to their own [dependencies]
color_quant = "=1.1.0" This will peg them to the exact version that is last compatible with Rust 1.34. |
The MSRV bump is fine, and is in fact wildly more conservative than we've been using for any of the other image-rs crates. |
Objective
image
is going to gainno_std
support, it would be beneficial for its dependencies to also haveno_std
support.Solution
#![no_std]
f64::abs
based on the proven implementation fromnum_traits
and comments on this PR.f64::round
intoclamp
and combined them into a new methodclamp_round
.alloc
crate.Notes
Since this crate doesn't need
std
, there's no need to add anstd
feature, making this PR suitable for a minor patch.