palette::cast

Trait AsUintsMut

source
pub trait AsUintsMut<A: ?Sized> {
    // Required method
    fn as_uints_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 unsigned integers 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::AsUintsMut, rgb::PackedArgb, Srgba};

let mut array: [PackedArgb; 2] = [
    Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into(),
    Srgba::new(0x5D, 0x12, 0xD6, 0xFF).into()
];
let slice_mut: &mut [PackedArgb] = &mut [
    Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into(),
    Srgba::new(0x5D, 0x12, 0xD6, 0xFF).into()
];
let mut vec: Vec<PackedArgb> = vec![
    Srgba::new(0x17, 0xC6, 0x4C, 0xFF).into(),
    Srgba::new(0x5D, 0x12, 0xD6, 0xFF).into()
];

assert_eq!(array.as_uints_mut(), &mut [0xFF17C64C, 0xFF5D12D6]);
assert_eq!(slice_mut.as_uints_mut(), &mut [0xFF17C64C, 0xFF5D12D6]);
assert_eq!(vec.as_uints_mut(), &mut [0xFF17C64C, 0xFF5D12D6]);

Required Methods§

source

fn as_uints_mut(&mut self) -> &mut A

Cast this collection of colors into a mutable collection of unsigned integers.

Implementations on Foreign Types§

source§

impl<'a, C> AsUintsMut<[<C as UintCast>::Uint]> for [C]
where C: UintCast,

source§

fn as_uints_mut(&mut self) -> &mut [C::Uint]

source§

impl<'a, C> AsUintsMut<[<C as UintCast>::Uint]> for Box<[C]>
where C: UintCast,

source§

fn as_uints_mut(&mut self) -> &mut [C::Uint]

source§

impl<'a, C> AsUintsMut<[<C as UintCast>::Uint]> for Vec<C>
where C: UintCast,

source§

fn as_uints_mut(&mut self) -> &mut [C::Uint]

source§

impl<'a, C, const N: usize> AsUintsMut<[<C as UintCast>::Uint]> for [C; N]
where C: UintCast,

source§

fn as_uints_mut(&mut self) -> &mut [C::Uint]

Implementors§