[][src]Struct screeps::RoomName

pub struct RoomName { /* fields omitted */ }

A structure representing a room name.

Methods

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 Clone for RoomName[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialEq<RoomName> for RoomName[src]

impl PartialEq<str> for RoomName[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<RoomName> for str[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<String> for RoomName[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<RoomName> for String[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Copy for RoomName[src]

impl Eq 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 Debug for RoomName[src]

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 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 Hash for RoomName[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

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

impl FromStr for RoomName[src]

type Err = RoomNameParseError

The associated error which can be returned from parsing.

impl JsSerialize for RoomName

impl TryFrom<Value> for RoomName

type Error = ConversionError

The type returned in the event of a conversion error.

impl TryFrom<RoomName> for Value

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_a> TryFrom<&'_a RoomName> for Value

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_a> TryFrom<&'_a mut RoomName> for Value

type Error = ConversionError

The type returned in the event of a conversion error.

impl JsSerializeOwned for RoomName

impl<'_r> JsSerializeOwned for &'_r RoomName

impl Serialize for RoomName[src]

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

Auto Trait Implementations

Blanket Implementations

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> From<T> for T[src]

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

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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]