pub fn from_component_slice_mut<T>(
values: &mut [<T::Array as ArrayExt>::Item],
) -> &mut [T]where
T: ArrayCast,
Expand description
The same as try_from_component_slice_mut
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 = &mut [64, 139, 10, 93, 18, 214];
assert_eq!(
cast::from_component_slice_mut::<Srgb<u8>>(components),
&mut [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)]
)
This panics:
ⓘ
use palette::{cast, Srgb};
let components = &mut [64, 139, 10, 93, 18, 214, 0, 123]; // Not a multiple of 3
cast::from_component_slice_mut::<Srgb<u8>>(components);