pub trait UintsAsMut<C>where
C: ?Sized,{
// Required method
fn uints_as_mut(&mut self) -> &mut C;
}
Expand description
Trait for casting a mutable reference to a collection of unsigned integers into a mutable reference to a 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::UintsAsMut, rgb::PackedArgb, Srgba};
let mut array: [_; 2] = [0xFF17C64C, 0xFF5D12D6];
let slice_mut: &mut [_] = &mut [0xFF17C64C, 0xFF5D12D6];
let mut vec: Vec<_> = vec![0xFF17C64C, 0xFF5D12D6];
let colors: &mut [PackedArgb] = array.uints_as_mut();
assert_eq!(
colors,
&mut [
Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into(),
Srgba::new(0x5D, 0x12, 0xD6, 0xFF).into()
]
);
let colors: &mut [PackedArgb] = slice_mut.uints_as_mut();
assert_eq!(
colors,
&mut [
Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into(),
Srgba::new(0x5D, 0x12, 0xD6, 0xFF).into()
]
);
let colors: &mut [PackedArgb] = vec.uints_as_mut();
assert_eq!(
colors,
&mut [
Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into(),
Srgba::new(0x5D, 0x12, 0xD6, 0xFF).into()
]
);
Required Methods§
sourcefn uints_as_mut(&mut self) -> &mut C
fn uints_as_mut(&mut self) -> &mut C
Cast this collection of unsigned integers into a mutable collection of colors.