-
Notifications
You must be signed in to change notification settings - Fork 136
Make crate no_std compatible #389
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
base: main
Are you sure you want to change the base?
Changes from all commits
4399b95
79312b1
2e0e98a
806c2f9
0d98d46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,13 @@ edition = "2021" | |
path = "lib.rs" | ||
|
||
[dependencies] | ||
cssparser = { path = ".." } | ||
serde = { version = "1.0", features = ["derive"], optional = true } | ||
cssparser = { path = "..", default-features = false } | ||
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } | ||
libm = "0.2.8" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I missed this. It seems this dependency should be optional, and only enabled if |
||
|
||
[features] | ||
default = ["std"] | ||
std = ["cssparser/std", "serde/std"] | ||
serde = ["cssparser/serde", "dep:serde"] | ||
|
||
[dev-dependencies] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
olanod marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[inline] | ||
pub(crate) fn f32_trunc(val: f32) -> f32 { | ||
#[cfg(feature = "std")] | ||
{ val.round() } | ||
#[cfg(not(feature = "std"))] | ||
{ libm::roundf(val) } | ||
} | ||
Comment on lines
+6
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a typo. Should call into trunc function not round functions |
||
|
||
#[inline] | ||
pub(crate) fn f32_round(val: f32) -> f32 { | ||
#[cfg(feature = "std")] | ||
{ val.round() } | ||
#[cfg(not(feature = "std"))] | ||
{ libm::roundf(val) } | ||
} | ||
|
||
#[inline] | ||
pub(crate) fn f64_pow(a: f64, b: f64) -> f64 { | ||
olanod marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[cfg(feature = "std")] | ||
{ f64::powf(a, b) } | ||
#[cfg(not(feature = "std"))] | ||
{ libm::pow(a, b) } | ||
} |
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.
Is this change needed?