Trait cosmic::cosmic_theme::palette::cast::ArraysAsMut
source · pub trait ArraysAsMut<C>where
C: ?Sized,{
// Required method
fn arrays_as_mut(&mut self) -> &mut C;
}
Expand description
Trait for casting a mutable reference to collection of arrays into a mutable reference to collection of colors 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::ArraysAsMut, Srgb};
let mut array: [_; 2] = [[64, 139, 10], [93, 18, 214]];
let slice_mut: &mut [_] = &mut [[64, 139, 10], [93, 18, 214]];
let mut vec: Vec<_> = vec![[64, 139, 10], [93, 18, 214]];
let colors: &mut [Srgb<u8>] = array.arrays_as_mut();
assert_eq!(colors, &mut [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)]);
let colors: &mut [Srgb<u8>] = slice_mut.arrays_as_mut();
assert_eq!(colors, &mut [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)]);
let colors: &mut [Srgb<u8>] = vec.arrays_as_mut();
assert_eq!(colors, &mut [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)]);
Required Methods§
sourcefn arrays_as_mut(&mut self) -> &mut C
fn arrays_as_mut(&mut self) -> &mut C
Cast this collection of arrays into a mutable collection of colors.