Struct FillCanvas

Source
pub struct FillCanvas<T> { /* private fields */ }
Expand description

FillCanvas is a wrapper around a matrix with special methods to fill the cells.

FillCanvas provides methods to fill individual cells with a value, or multiple cells from a row/column or just all cells within an area at once.

The filled cells have a T value != the Default::default().

PS: Initially developed to have EntityIDs (from ECS) filled into a matrix based on the space they occupy on a canvas grid.

Implementations§

Source§

impl<T> FillCanvas<T>
where T: Default + Clone + PartialEq,

Source

pub fn new(rows: usize, cols: usize) -> Self

Source

pub fn resize(&mut self, rows: usize, cols: usize)

Source

pub fn clear(&mut self)

Source

pub fn get(&self, r: usize, c: usize) -> Option<&T>

Source

pub fn get_filled(&self, r: usize, c: usize) -> Option<&T>

Source

pub fn fill_cell(&mut self, v: T, r: usize, c: usize) -> Option<()>

Source

pub fn fill_row(&mut self, v: T, r: usize) -> Option<()>

Source

pub fn fill_col(&mut self, v: T, c: usize) -> Option<()>

Source

pub fn fill_area( &mut self, v: T, r0: usize, c0: usize, r1: usize, c1: usize, ) -> Option<()>

Trait Implementations§

Source§

impl<T> Display for FillCanvas<T>
where T: Clone + Default + Display + PartialEq,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FillCanvas<T>

§

impl<T> RefUnwindSafe for FillCanvas<T>
where T: RefUnwindSafe,

§

impl<T> Send for FillCanvas<T>
where T: Send,

§

impl<T> Sync for FillCanvas<T>
where T: Sync,

§

impl<T> Unpin for FillCanvas<T>
where T: Unpin,

§

impl<T> UnwindSafe for FillCanvas<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.