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

fix no_std #127

Merged
merged 4 commits into from Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion palette/src/blend/blend.rs
@@ -1,6 +1,6 @@
use num_traits::{One, Zero};
use float::Float;
#[cfg(feature = "libm_works")]
#[cfg(not(feature = "std"))]
use num_traits::float::FloatCore;

use {cast, clamp, ComponentWise};
Expand Down
2 changes: 1 addition & 1 deletion palette/src/blend/equations.rs
@@ -1,5 +1,5 @@
use float::Float;
#[cfg(feature = "libm_works")]
#[cfg(not(feature = "std"))]
use num_traits::float::FloatCore;

use {Blend, ComponentWise};
Expand Down
4 changes: 2 additions & 2 deletions palette/src/convert.rs
Expand Up @@ -391,7 +391,7 @@ where
/// 0.7353569830524495,
/// 0.5370987304831942,
/// ];
/// let hsv = Bgr::from_raw_slice(&buffer)[1].into();
/// let hsv: Hsv<palette::encoding::Srgb, _> = Bgr::from_raw_slice(&buffer)[1].into();
Copy link
Owner

@Ogeon Ogeon Mar 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't just Hsv enough? Srgb should be the default. Or was Srgb what it couldn't infer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah strangely enough, just Hsv didn't seem to be enough :(

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd. Oh well. In that case can you add Srgb to the import at the top of the example? That would make this part a bit less noisy... I don't know if you tried it, but you may be able to skip the _ at least, unless I'm forgetting something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would conflict with palette::Srgb imported above - do you have a preferred alias for the Srgb encoding? (e.g. eSrgb or similar?)

I have tried without the _ and that doesn't seem to be enough.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, good job on me for not reading it all. It's also f64, not the default f32, so that's probably why _ has to be there.

Uhm... I usually prefer to spell it out if I can... You could put a self in the encoding import and at least shorten it down to encoding::Srgb, I guess. :) If that makes a difference. I'm just trying to put the focus on the right hand expression, but it's not that important.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you can create an alias like type Hsv64 = Hsv<encoding::Srgb, f64>;!

///
/// assert_relative_eq!(hsv, Hsv::new(90.0, 1.0, 0.5));
/// }
Expand Down Expand Up @@ -441,7 +441,7 @@ where
/// blue: 255,
/// alpha: 0.3,
/// };
/// let color = css_color.into();
/// let color: LinSrgba = css_color.into();
///
/// assert_relative_eq!(color, LinSrgba::new(0.496933, 0.0, 1.0, 0.3));
/// }
Expand Down
5 changes: 3 additions & 2 deletions palette/src/float.rs
Expand Up @@ -9,12 +9,13 @@
//!
//! [`libm`]: https://github.com/japaric/libm

#[cfg(feature = "std")]
pub use num_traits::Float;

#[cfg(feature = "libm_works")]
#[cfg(not(feature = "std"))]
pub use self::no_std_float_trait::Float;

#[cfg(feature = "libm_works")]
#[cfg(not(feature = "std"))]
mod no_std_float_trait {
extern crate libm;
use self::libm::{F32Ext, F64Ext};
Expand Down