pub struct RoomName { /* private fields */ }
Expand description

A structure representing a room name.

Ordering

To facilitate use as a key in a BTreeMap or other similar data structures, RoomName implements PartialOrd and Ord.

RoomNames are ordered first by y position, then by x position. North is considered less than south, and west less than east.

The total ordering is N127W127, N127W126, N127W125, …, N127W0, N127E0, …, N127E127, N126W127, …, S127E126, S127E127.

This follows left-to-right reading order when looking at the Screeps map from above.

Implementations

Parses a room name from a string.

This will parse the input string, returning an error if it is in an invalid room name.

The expected format can be represented by the regex [ewEW][0-9]+[nsNS][0-9]+.

Converts this RoomName into an efficient, stack-based string.

This is equivalent to ToString::to_string, but involves no allocation.

Trait Implementations

Offsets this room name by a given horizontal and vertical (x, y) pair.

The first number offsets to the west when negative and to the east when positive. The first number offsets to the north when negative and to the south when positive.

Panics

Will panic if the addition overflows the boundaries of RoomName.

The resulting type after applying the + operator.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats this room name into the format the game expects.

Resulting string will be (E|W)[0-9]+(N|S)[0-9]+, and will result in the same RoomName if passed into RoomName::new.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Offsets this room name in the opposite direction from the coordinates.

See the implementation for Add<(i32, i32)>.

Panics

Will panic if the subtraction overflows the boundaries of RoomName.

The resulting type after applying the - operator.

Subtracts one room name from the other, extracting the difference.

The first return value represents east/west offset, with ‘more east’ being positive and ‘more west’ being negative.

The second return value represents north/south offset, with ‘more south’ being positive and ‘more north’ being negative.

This coordinate system agrees with the implementations Add<(i32, i32)> for RoomName and Sub<(i32, i32)> for RoomName.

The resulting type after applying the - operator.

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.

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.

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.

Casts this value as the target type, making the assumption that the types are correct. Read more

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.

The type returned in the event of a conversion error.

Performs the conversion.