[−][src]Struct screeps::RoomName
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
.
RoomName
s 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]
T: AsRef<str>,
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]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
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.
fn from_str(s: &str) -> Result<Self, RoomNameParseError>
[src]
impl Hash for RoomName
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl JsSerialize for RoomName
[src]
impl JsSerializeOwned for RoomName
[src]
fn into_js_owned<'_a>(value: &'_a mut Option<Self>) -> SerializedValue<'_a>
[src]
impl<'_r> JsSerializeOwned for &'_r RoomName
[src]
fn into_js_owned<'_a>(value: &'_a mut Option<Self>) -> SerializedValue<'_a>
[src]
impl Ord for RoomName
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[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]
fn partial_cmp(&self, other: &RoomName) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[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.
fn try_from(value: &'_a RoomName) -> Result<Self, Self::Error>
[src]
impl<'_a> TryFrom<&'_a mut RoomName> for Value
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: &'_a mut RoomName) -> Result<Self, Self::Error>
[src]
impl TryFrom<RoomName> for Value
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: RoomName) -> Result<Self, Self::Error>
[src]
impl TryFrom<Value> for RoomName
[src]
Auto Trait Implementations
impl RefUnwindSafe for RoomName
impl Send for RoomName
impl Sync for RoomName
impl Unpin for RoomName
impl UnwindSafe for RoomName
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoExpectedType<U> for T where
U: FromExpectedType<T>,
[src]
U: FromExpectedType<T>,
fn into_expected_type(Self) -> Result<U, ConversionError>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,