Function cosmic::cosmic_theme::palette::cast::into_array_box
source · pub fn into_array_box<T>(value: Box<T>) -> Box<<T as ArrayCast>::Array>where
T: ArrayCast,
Expand description
Cast from a boxed color type to a boxed array.
use palette::{cast, Srgb};
let color = Box::new(Srgb::new(23u8, 198, 76));
assert_eq!(cast::into_array_box(color), Box::new([23, 198, 76]));
It’s also possible to use From
and Into
when casting built-in types:
use palette::Srgb;
// Boxed colors implement `Into`:
let color1 = Box::new(Srgb::new(23u8, 198, 76));
let array1: Box<[_; 3]> = color1.into();
// Boxed arrays implement `From`:
let color2 = Box::new(Srgb::new(23u8, 198, 76));
let array2 = <Box<[_; 3]>>::from(color2);