Trait cosmic::cosmic_theme::palette::cast::AsArrays

source ·
pub trait AsArrays<A>
where A: ?Sized,
{ // Required method fn as_arrays(&self) -> &A; }
Expand description

Trait for casting a reference to a collection of colors into a 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::AsArrays, Srgb};

let array: [_; 2] = [Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)];
let slice: &[_] = &[Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)];
let vec: Vec<_> = vec![Srgb::new(64u8, 139, 10), Srgb::new(93, 18, 214)];

assert_eq!(array.as_arrays(), &[[64, 139, 10], [93, 18, 214]]);
assert_eq!(slice.as_arrays(), &[[64, 139, 10], [93, 18, 214]]);
assert_eq!(vec.as_arrays(), &[[64, 139, 10], [93, 18, 214]]);

Required Methods§

source

fn as_arrays(&self) -> &A

Cast this collection of colors into a collection of arrays.

Implementations on Foreign Types§

source§

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

source§

fn as_arrays(&self) -> &[[T; N]]

source§

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

source§

fn as_arrays(&self) -> &[[T; N]]

source§

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

source§

fn as_arrays(&self) -> &[[T; N]]

source§

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

source§

fn as_arrays(&self) -> &[[T; N]]

Implementors§