Function cosmic::cosmic_theme::palette::cast::from_array_mut
source · pub fn from_array_mut<T>(value: &mut <T as ArrayCast>::Array) -> &mut Twhere
T: ArrayCast,
Expand description
Cast from a mutable array reference to a mutable color type reference.
use palette::{cast, Srgb};
let mut array = [23, 198, 76];
assert_eq!(cast::from_array_mut::<Srgb<u8>>(&mut array), &mut Srgb::new(23, 198, 76));
It’s also possible to use From
, Into
and AsMut
when casting built-in
types:
use palette::Srgb;
let mut array = [23, 198, 76];
// Arrays implement `AsMut`:
let color1: &mut Srgb<u8> = array.as_mut();
// Array references implement `Into`:
let color2: &mut Srgb<u8> = (&mut array).into();
// Color references implement `From`:
let color3 = <&mut Srgb<u8>>::from(&mut array);