[][src]Struct smeagol::Position

pub struct Position {
    pub x: i64,
    pub y: i64,
}

The position of a cell in a Life grid.

Fields

x: i64

The x coordinate.

y: i64

The y coordinate.

Methods

impl Position[src]

pub fn new(x: i64, y: i64) -> Self[src]

Creates a new position with the given coordinates.

Exampes

let position = smeagol::Position::new(1, 2);

pub fn offset(&self, x_offset: i64, y_offset: i64) -> Self[src]

Offsets the position by the given amounts in the x and y directions.

Examples

let pos = smeagol::Position::new(1, 2);
assert_eq!(pos.offset(3, 4), smeagol::Position::new(4, 6));

pub fn quadrant(&self) -> Quadrant[src]

Returns which quadrant of a node the position is in.

Examples

assert_eq!(
    smeagol::Position::new(-1, -1).quadrant(),
    smeagol::node::Quadrant::Northwest
);
assert_eq!(
    smeagol::Position::new(-1, 0).quadrant(),
    smeagol::node::Quadrant::Southwest
);
assert_eq!(
    smeagol::Position::new(0, -1).quadrant(),
    smeagol::node::Quadrant::Northeast
);
assert_eq!(
    smeagol::Position::new(0, 0).quadrant(),
    smeagol::node::Quadrant::Southeast
);

Trait Implementations

impl PartialEq<Position> for Position[src]

impl Clone for Position[src]

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

Performs copy-assignment from source. Read more

impl PartialOrd<Position> for Position[src]

impl Eq for Position[src]

impl Ord for Position[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Copy for Position[src]

impl Debug for Position[src]

impl Hash for Position[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

Auto Trait Implementations

impl Send for Position

impl Sync for Position

Blanket Implementations

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

type Owned = T

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

impl<T> From for T[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> FromCast for T[src]

impl<T, U> Cast for T where
    U: FromCast<T>, 
[src]