pub fn from_component_slice_box<T>(
values: Box<[<T::Array as ArrayExt>::Item]>,
) -> Box<[T]>where
T: ArrayCast,
Expand description
The same as try_from_component_slice_box
but panics on error.
§Panics
The cast will panic if the length of the input slice is not a multiple of the color’s array length.
§Examples
use palette::{cast, Srgb};
let components = vec![64, 139, 10, 93, 18, 214].into_boxed_slice();
assert_eq!(
cast::from_component_slice_box::<Srgb<u8>>(components),
vec![Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)].into_boxed_slice()
)
This panics:
ⓘ
use palette::{cast, Srgb};
// Not a multiple of 3:
let components = vec![64, 139, 10, 93, 18, 214, 0, 123].into_boxed_slice();
cast::from_component_slice_box::<Srgb<u8>>(components);