ColorIterMut

Trait ColorIterMut 

Source
pub trait ColorIterMut: Sized {
    // Required method
    fn fill(self, color: ColorRGB);

    // Provided method
    fn clear(self) { ... }
}
Expand description

Useful methods when iterating over ColorRGBs.

This is impl’d for any Iterator over &mut RGB. This includes both arrays and slices, the most common use case for this.

§Examples

Operating Directly on an array of ColorRGBs:

use cichlid::{prelude::*, ColorRGB};

let mut colors = [ColorRGB::BlanchedAlmond; 100];

colors.fill(ColorRGB::Yellow);
colors.iter().for_each(|c| assert_eq!(*c, ColorRGB::Yellow));

Operating on slices is supported as well:

use cichlid::{prelude::*, ColorRGB};

let mut colors = [ColorRGB::Purple; 50];
let color_slice = &mut colors[0..40];

color_slice.clear();
color_slice.iter().for_each(|c| assert_eq!(*c, ColorRGB::Black));

Required Methods§

Source

fn fill(self, color: ColorRGB)

Fills an entire Iterator with the specified color.

Provided Methods§

Source

fn clear(self)

Sets all colors to black.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T: Sized + IntoIterator<Item = &'a mut ColorRGB>> ColorIterMut for T