Function cosmic::cosmic_theme::palette::cast::from_array_box

source ·
pub fn from_array_box<T>(value: Box<<T as ArrayCast>::Array>) -> Box<T>
where T: ArrayCast,
Expand description

Cast from a boxed array to a boxed color type.

use palette::{cast, Srgb};

let array = Box::new([23, 198, 76]);
assert_eq!(cast::from_array_box::<Srgb<u8>>(array),  Box::new(Srgb::new(23, 198, 76)));

It’s also possible to use From and Into when casting built-in types:

use palette::Srgb;


// Boxed arrays implement `Into`:
let array1 = Box::new([23, 198, 76]);
let color1: Box<Srgb<u8>> = array1.into();

// Boxed colors implement `From`:
let array2 = Box::new([23, 198, 76]);
let color2 = <Box<Srgb<u8>>>::from(array2);