pub trait AsArraysMut<A: ?Sized> {
// Required method
fn as_arrays_mut(&mut self) -> &mut A;
}
Expand description
Trait for casting a mutable reference to a collection of colors into a mutable reference to a collection of arrays without copying.
This trait is meant as a more convenient alternative to the free functions
in cast
, to allow method chaining among other things.
§Examples
use palette::{cast::AsArraysMut, Srgb};
let mut array: [_; 2] = [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)];
let slice_mut: &mut [_] = &mut [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)];
let mut vec: Vec<_> = vec![Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)];
assert_eq!(array.as_arrays_mut(), &mut [[64, 139, 10], [93, 18, 214]]);
assert_eq!(slice_mut.as_arrays_mut(), &mut [[64, 139, 10], [93, 18, 214]]);
assert_eq!(vec.as_arrays_mut(), &mut [[64, 139, 10], [93, 18, 214]]);
Required Methods§
sourcefn as_arrays_mut(&mut self) -> &mut A
fn as_arrays_mut(&mut self) -> &mut A
Cast this collection of colors into a mutable collection of arrays.