Struct gridit::Step[][src]

pub struct Step { /* fields omitted */ }

A Step or direction to the next position in the grid, always relative to a position.

Implementations

impl Step[src]

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

Create a new step.

Example

let step = Step::new(1, 2);
assert_eq!(step, Step::from((1, 2)));

pub fn negate_x(self) -> Self[src]

Negate the x value of the step. This is usefull when a step is needed with a x value larger then i32.

let step = Step::new(2, 2)
                .negate_x();
assert_eq!(step, Step::from((-2, 2)));

pub fn negate_y(self) -> Self[src]

Negate the y value of the step. This is usefull when a step is needed with a y value larger then i32.

let step = Step::new(2, 2)
                .negate_y();
assert_eq!(step, (2, -2).into());

Trait Implementations

impl Clone for Step[src]

fn clone(&self) -> Step[src]

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Debug for Step[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<(i32, i32)> for Step[src]

fn from((x, y): (i32, i32)) -> Self[src]

Performs the conversion.

impl From<(isize, isize)> for Step[src]

fn from((x, y): (isize, isize)) -> Self[src]

Performs the conversion.

impl From<(usize, usize)> for Step[src]

fn from((x, y): (usize, usize)) -> Self[src]

Performs the conversion.

impl PartialEq<Step> for Step[src]

fn eq(&self, other: &Step) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Step) -> bool[src]

This method tests for !=.

impl Copy for Step[src]

impl Eq for Step[src]

impl StructuralEq for Step[src]

impl StructuralPartialEq for Step[src]

Auto Trait Implementations

impl RefUnwindSafe for Step

impl Send for Step

impl Sync for Step

impl Unpin for Step

impl UnwindSafe for Step

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.