Trait cosmic::cosmic_theme::palette::cast::AsComponentsMut

source ·
pub trait AsComponentsMut<C>
where C: ?Sized,
{ // Required method fn as_components_mut(&mut self) -> &mut C; }
Expand description

Trait for casting a mutable reference to a collection of colors into a mutable reference to a collection of color components 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::AsComponentsMut, 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_components_mut(), &mut [64, 139, 10, 93, 18, 214]);
assert_eq!(slice_mut.as_components_mut(), &mut [64, 139, 10, 93, 18, 214]);
assert_eq!(vec.as_components_mut(), &mut [64, 139, 10, 93, 18, 214]);

Required Methods§

source

fn as_components_mut(&mut self) -> &mut C

Cast this collection of colors into a mutable collection of color components.

Implementations on Foreign Types§

source§

impl<'a, T, C, const N: usize> AsComponentsMut<[T]> for [C]
where C: ArrayCast<Array = [T; N]>,

source§

fn as_components_mut(&mut self) -> &mut [T]

source§

impl<'a, T, C, const N: usize> AsComponentsMut<[T]> for Box<[C]>
where C: ArrayCast<Array = [T; N]>,

source§

fn as_components_mut(&mut self) -> &mut [T]

source§

impl<'a, T, C, const N: usize> AsComponentsMut<[T]> for Vec<C>
where C: ArrayCast<Array = [T; N]>,

source§

fn as_components_mut(&mut self) -> &mut [T]

source§

impl<'a, T, C, const N: usize, const M: usize> AsComponentsMut<[T]> for [C; M]
where C: ArrayCast<Array = [T; N]>,

source§

fn as_components_mut(&mut self) -> &mut [T]

Implementors§