Struct sqrid::Grid

source ·
pub struct Grid<T, const WIDTH: u16, const HEIGHT: u16, const SIZE: usize>(_);
Expand description

A grid is a generic array that can be indexed by a Qa

We can also interact with specific lines with Grid::line and Grid::line_mut, or with the whole underlying array with as_ref and as_mut.

At the moment we have to provide a SIZE argument = WIDTH * HEIGHT. This value is checked at compile time, but can’t be ellided at the moment, due to rust const generics limitations.

We can use the grid_create macro to use a Qa as a source of these values.

Implementations§

Number of elements in the grid.

Create a grid filled with copies of the provided item

This is the fastest of the repeat_* functions, that’s why it’s the “default”.

Create a grid filled with copies of the provided item

“Dismantle” a Grid into the inner array; consumes self.

Return a reference to the inner array

Return a mut reference to the inner array

Return a specific grid line as a reference to a slice

Return a specific grid line as a mut reference to a slice

Allows quick assignment operations on whole lines.

Get a reference to an element of the grid.

We use get_unchecked internally, because we guarantee the validity of the Qa index on construction.

Get a mut reference to an element of the grid.

We use get_unchecked internally, because we guarantee the validity of the Qa index on construction.

Returns an iterator over the grid values

Returns an iterator that allows modifying each value

Returns an iterator over the grid coordinates and values

Flip all elements horizontally.

Flip all elements vertically.

Rotate all elements 90 degrees clockwise

Rotate all elements 90 degrees counterclockwise

Trait Implementations§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Pretty-printer Grid display implementation

The Display implementation of grid was made to print an ascii-like grid. It does that in one pass, and uses the padding parameter as the size to reserve for each member.

Formats the value using the given formatter. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Creates a Grid from an iterator that returns references

Assumes we are getting exactly all grid elements; it panics otherwise.

Creates a value from an iterator. Read more

Creates a Grid from an iterator that returns values

Assumes we are getting exactly all grid elements; it panics otherwise.

Creates a value from an iterator. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
Create a new MapQa with the provided value for all items
Get the item corresponding to the provided Qa
Set the item corresponding to the provided Qa
The resulting type after applying the - operator.
Performs the unary - operation. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.