Struct aglet::Coord

source · []
pub struct Coord {
    pub x: u32,
    pub y: u32,
}
Expand description

Unsigned-int coordinates

Fields

x: u32y: u32

Implementations

Make a new coord.

Get this as an index into an array representing a 2d array.

(AKA, y * width + x.)

Convert this into an ICoord.

Get a list of this coordinate’s orthagonal neighbors. They are given in clockwise order starting with the neighbor to the north, as if each of Direction4::DIRECTIONS had been added to them.

If a neighbor is out of bounds, it is skipped in the output.

There may be 2, 3, or 4 neighbors:

  • 2 if this is at (0, 0)
  • 3 if this is on an edge (x or y are 0)
  • 4 otherwise.

Get a list of this coordinate’s orthagonal and diagonal neighbors. They are given in clockwise order starting with the neighbor to the north, as if each of Direction8::DIRECTIONS had been added to them.

If a neighbor is out of bounds, it is skipped in the output.

There may be 3, 5, or 8 neighbors:

  • 3 if this is at (0, 0)
  • 5 if this is on an edge (x or y are 0)
  • 8 otherwise. Direction8::DIRECTIONS: super::Direction8::DIRECTIONS

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Try to convert an ICoord to a Coord. Will return Error if the ICoord has any negatives in it.

The type returned in the event of a conversion error.

Performs the conversion.

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.