Function palette::cast::into_array_mut

source ·
pub fn into_array_mut<T>(value: &mut T) -> &mut T::Array
where T: ArrayCast,
Expand description

Cast from a mutable color type reference to a mutable array reference.

use palette::{cast, Srgb};

let mut color = Srgb::new(23u8, 198, 76);
assert_eq!(cast::into_array_mut(&mut color), &mut [23, 198, 76]);

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

use palette::Srgb;

let mut color = Srgb::new(23u8, 198, 76);

// Colors implement `AsMut`:
let array1: &mut [_; 3] = color.as_mut();

// Color references implement `Into`:
let array2: &mut [_; 3] = (&mut color).into();
// Array references implement `From`:
let array3 = <&mut [_; 3]>::from(&mut color);