#[repr(u8)]pub enum Direction {
    Top = 1,
    TopRight = 2,
    Right = 3,
    BottomRight = 4,
    Bottom = 5,
    BottomLeft = 6,
    Left = 7,
    TopLeft = 8,
}Expand description
Translates direction constants.
Variants§
Implementations§
source§impl Direction
 
impl Direction
sourcepub fn is_orthogonal(self) -> bool
 
pub fn is_orthogonal(self) -> bool
Whether the direction is orthogonal.
Example usage:
use screeps::Direction::*;
assert_eq!(Top.is_orthogonal(), true);
assert_eq!(TopRight.is_orthogonal(), false);sourcepub fn is_diagonal(self) -> bool
 
pub fn is_diagonal(self) -> bool
Whether the direction is diagonal.
Example usage:
use screeps::Direction::*;
assert_eq!(Top.is_diagonal(), false);
assert_eq!(TopRight.is_diagonal(), true);sourcepub fn multi_rot(self, times: i8) -> Self
 
pub fn multi_rot(self, times: i8) -> Self
Rotate the direction by a specified number of steps clockwise if positive or counter-clockwise if negative.
Example usage:
use screeps::Direction::*;
assert_eq!(Top.multi_rot(1), TopRight);
assert_eq!(Top.multi_rot(2), Right);
assert_eq!(Top.multi_rot(-1), TopLeft);
assert_eq!(Top.multi_rot(-2), Left);
assert_eq!(Top.multi_rot(64), Top);Trait Implementations§
source§impl<'de> Deserialize<'de> for Direction
 
impl<'de> Deserialize<'de> for Direction
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
    D: Deserializer<'de>,
 
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<ExitDirection> for Direction
 
impl From<ExitDirection> for Direction
source§fn from(dir: ExitDirection) -> Self
 
fn from(dir: ExitDirection) -> Self
Converts to this type from the input type.
source§impl FromPrimitive for Direction
 
impl FromPrimitive for Direction
source§fn from_i64(n: i64) -> Option<Self>
 
fn from_i64(n: i64) -> Option<Self>
Converts an 
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_u64(n: u64) -> Option<Self>
 
fn from_u64(n: u64) -> Option<Self>
Converts an 
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_isize(n: isize) -> Option<Self>
 
fn from_isize(n: isize) -> Option<Self>
Converts an 
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_i8(n: i8) -> Option<Self>
 
fn from_i8(n: i8) -> Option<Self>
Converts an 
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_i16(n: i16) -> Option<Self>
 
fn from_i16(n: i16) -> Option<Self>
Converts an 
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_i32(n: i32) -> Option<Self>
 
fn from_i32(n: i32) -> Option<Self>
Converts an 
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_i128(n: i128) -> Option<Self>
 
fn from_i128(n: i128) -> Option<Self>
Converts an 
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moresource§fn from_usize(n: usize) -> Option<Self>
 
fn from_usize(n: usize) -> Option<Self>
Converts a 
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_u8(n: u8) -> Option<Self>
 
fn from_u8(n: u8) -> Option<Self>
Converts an 
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_u16(n: u16) -> Option<Self>
 
fn from_u16(n: u16) -> Option<Self>
Converts an 
u16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_u32(n: u32) -> Option<Self>
 
fn from_u32(n: u32) -> Option<Self>
Converts an 
u32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.source§fn from_u128(n: u128) -> Option<Self>
 
fn from_u128(n: u128) -> Option<Self>
Converts an 
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moresource§impl FromWasmAbi for Direction
 
impl FromWasmAbi for Direction
source§impl IntoWasmAbi for Direction
 
impl IntoWasmAbi for Direction
source§impl JsCollectionIntoValue for Direction
 
impl JsCollectionIntoValue for Direction
fn into_value(self) -> JsValue
source§impl Neg for Direction
 
impl Neg for Direction
source§impl OptionFromWasmAbi for Direction
 
impl OptionFromWasmAbi for Direction
source§impl OptionIntoWasmAbi for Direction
 
impl OptionIntoWasmAbi for Direction
source§impl PartialEq for Direction
 
impl PartialEq for Direction
source§impl Sequence for Direction
 
impl Sequence for Direction
source§impl TryFromJsValue for Direction
 
impl TryFromJsValue for Direction
source§impl VectorFromWasmAbi for Direction
 
impl VectorFromWasmAbi for Direction
source§impl VectorIntoWasmAbi for Direction
 
impl VectorIntoWasmAbi for Direction
impl Copy for Direction
impl Eq for Direction
impl StructuralEq for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnwindSafe for Direction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> ReturnWasmAbi for Twhere
    T: IntoWasmAbi,
 
impl<T> ReturnWasmAbi for Twhere T: IntoWasmAbi,
§type Abi = <T as IntoWasmAbi>::Abi
 
type Abi = <T as IntoWasmAbi>::Abi
Same as 
IntoWasmAbi::Abisource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
 
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as 
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.