[][src]Struct screeps::RoomName

pub struct RoomName { /* fields omitted */ }

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

impl RoomName[src]

pub fn new<T: ?Sized>(x: &T) -> Result<Self, RoomNameParseError> where
    T: AsRef<str>, 
[src]

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]+.

pub fn to_array_string(&self) -> ArrayString<[u8; 8]>[src]

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

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

Trait Implementations

impl Add<(i32, i32)> for RoomName[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, (x, y): (i32, i32)) -> Self[src]

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.

impl Clone for RoomName[src]

impl Copy for RoomName[src]

impl Debug for RoomName[src]

impl<'de> Deserialize<'de> for RoomName[src]

impl Display for RoomName[src]

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

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.

impl Eq for RoomName[src]

impl FromStr for RoomName[src]

type Err = RoomNameParseError

The associated error which can be returned from parsing.

impl Hash for RoomName[src]

impl JsSerialize for RoomName[src]

impl JsSerializeOwned for RoomName[src]

impl<'_r> JsSerializeOwned for &'_r RoomName[src]

impl Ord for RoomName[src]

impl<'_> PartialEq<&'_ String> for RoomName[src]

impl<'_> PartialEq<&'_ str> for RoomName[src]

impl PartialEq<RoomName> for RoomName[src]

impl PartialEq<RoomName> for str[src]

impl<'_> PartialEq<RoomName> for &'_ str[src]

impl PartialEq<RoomName> for String[src]

impl<'_> PartialEq<RoomName> for &'_ String[src]

impl PartialEq<String> for RoomName[src]

impl PartialEq<str> for RoomName[src]

impl PartialOrd<RoomName> for RoomName[src]

impl Serialize for RoomName[src]

impl StructuralEq for RoomName[src]

impl StructuralPartialEq for RoomName[src]

impl Sub<(i32, i32)> for RoomName[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, (x, y): (i32, i32)) -> Self[src]

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.

impl Sub<RoomName> for RoomName[src]

type Output = (i32, i32)

The resulting type after applying the - operator.

fn sub(self, other: RoomName) -> (i32, i32)[src]

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.

impl<'_a> TryFrom<&'_a RoomName> for Value[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_a> TryFrom<&'_a mut RoomName> for Value[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl TryFrom<RoomName> for Value[src]

type Error = ConversionError

The type returned in the event of a conversion error.

impl TryFrom<Value> for RoomName[src]

type Error = ConversionError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoExpectedType<U> for T where
    U: FromExpectedType<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.