pub trait Shape: Clone {
    type Axis: Axis;
    type Coordinate: Coordinate;
    type OffsetConvertError: Debug + Clone;
    type CoordinateMoveError: Debug + Clone;
Show 16 methods fn horizontal(&self) -> usize;
fn vertical(&self) -> usize;
fn to_offset(
        &self,
        coord: Self::Coordinate
    ) -> Result<Offset, Self::OffsetConvertError>;
fn from_offset(&self, offset: Offset) -> Self::Coordinate;
fn move_coord(
        &self,
        coord: Self::Coordinate,
        dir: <Self::Axis as Axis>::Direction
    ) -> Result<Self::Coordinate, Self::CoordinateMoveError>; fn node_count(&self) -> usize { ... }
unsafe fn to_offset_unchecked(&self, coord: Self::Coordinate) -> Offset { ... }
fn from_index(&self, index: usize) -> Self::Coordinate { ... }
fn to_index(&self, coord: Self::Coordinate) -> Option<usize> { ... }
fn index_to_offset(&self, index: usize) -> Offset { ... }
fn offset_to_index(&self, o: Offset) -> usize { ... }
fn horizontal_edge_size(&self, _axis: Self::Axis) -> usize { ... }
fn vertical_edge_size(&self, _axis: Self::Axis) -> usize { ... }
unsafe fn move_coord_unchecked(
        &self,
        coord: Self::Coordinate,
        dir: <Self::Axis as Axis>::Direction
    ) -> Self::Coordinate { ... }
fn is_neighbor(&self, a: Self::Coordinate, b: Self::Coordinate) -> bool { ... }
fn get_direction(
        &self,
        source: Self::Coordinate,
        target: Self::Coordinate
    ) -> Option<<Self::Axis as Axis>::Direction> { ... }
}
Expand description

Shape of the 2d lattice. It decides the behavior of the coordinate.

Associated Types

Axis of the lattice.

Coordinate of the lattice graph.

Error to return when to_offset fails. Should set Infallible when the graph is looped and never to fail.

Error to return when move_coord fails. Should set Infallible when the graph is looped and never to fail.

Required methods

Horizontal node count.

Vertical node count.

Convert coordinate to Offset.

Convert coordinate from Offset.

Move coordinates to the next coordinate in the direction. Coordinate should be a valid coordinate and should be checked before using move_coord. This is because the target coordinate might be valid even thought the souce coord is invalid, and some code validate the direction by moveing the coord.

Provided methods

Node count.

Convert coordinate to Offset without a check.

Convert coordinate from index.

Covert coordinate to index.

Convert index to offset.

Covert offset to index.

👎 Deprecated

Edge count of horizontal. May differ by the axis info.

👎 Deprecated

Edge count of vertical. May differ by the axis info.

Move coordinates to the next coordinate in the direction. Caller should be sure that the source and the target coord is valid coord.

Check whether two coordinate is in neighbor.

Get direction if two coordiante is in neighbor.

Implementations on Foreign Types

Implementors