Trait palette::convert::TryIntoColor[][src]

pub trait TryIntoColor<T>: Sized {
    fn try_into_color(self) -> Result<T, OutOfBounds<T>>;
}

A trait for fallible conversion of a color into another.

U: TryIntoColor<T> is implemented for every type T: TryFromColor<U>.

See TryFromColor for more details.

Required methods

fn try_into_color(self) -> Result<T, OutOfBounds<T>>[src]

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color.

 use palette::convert::TryIntoColor;
 use palette::{Hsl, Srgb};

 let rgb: Srgb = match Hsl::new(150.0, 1.0, 1.1).try_into_color() {
     Ok(color) => color,
     Err(err) => {
         println!("Color is out of bounds");
         err.color()
     }
 };
Loading content...

Implementors

impl<T, U> TryIntoColor<U> for T where
    U: TryFromColor<T>, 
[src]

Loading content...