[−][src]Struct smeagol::Position
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(&self) -> 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]
fn partial_cmp(&self, other: &Position) -> Option<Ordering>
[src]
fn lt(&self, other: &Position) -> bool
[src]
fn le(&self, other: &Position) -> bool
[src]
fn gt(&self, other: &Position) -> bool
[src]
fn ge(&self, other: &Position) -> bool
[src]
impl Eq for Position
[src]
impl Ord for Position
[src]
fn cmp(&self, other: &Position) -> Ordering
[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]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> FromCast for T
[src]
impl<T, U> Cast for T where
U: FromCast<T>,
[src]
U: FromCast<T>,