[−][src]Struct gridd::Offset
A two-dimensional offset vector used to relate grid elements spatially.
Fields
col_offset: i32
row_offset: i32
Methods
impl Offset
[src]
pub const NORTH: Offset
[src]
Northern unit vector: (col: +0, row: -1).
pub const EAST: Offset
[src]
Eastern unit vector: (col: +1, row: +0).
pub const SOUTH: Offset
[src]
Southern unit vector: (col: +0, row: +1).
pub const WEST: Offset
[src]
Western unit vector: (col: -1, row: +0).
pub fn cardinal_sum(n: i32, e: i32, s: i32, w: i32) -> Self
[src]
Create a new Offset
from the sum of cardinal vectors.
Examples
use gridd::Offset; assert_eq!( Offset::cardinal_sum(1, 0, -1, 0), Offset::NORTH - Offset::SOUTH ); assert_eq!( Offset::cardinal_sum(0, 2, 0, 3), 2 * Offset::EAST + 3 * Offset::WEST );
pub fn rcoord(&self, (col, row): Coord) -> Option<Coord>
[src]
Get the coordinate pointed to by an Offset
from a given Coord
.
Returns None
when either Coord
component would be negative.
Examples
use gridd::{Coord, Offset}; let coord: Coord = (3, 5); let v1 = Offset::from((-3, 2)); assert_eq!(Some((0, 7)), v1.rcoord(coord)); let v2 = Offset::from((-4, 5)); assert_eq!(None, v2.rcoord(coord));
Trait Implementations
impl Eq for Offset
[src]
impl Default for Offset
[src]
impl Clone for Offset
[src]
impl PartialOrd<Offset> for Offset
[src]
fn partial_cmp(&self, other: &Offset) -> Option<Ordering>
[src]
fn lt(&self, other: &Offset) -> bool
[src]
fn le(&self, other: &Offset) -> bool
[src]
fn gt(&self, other: &Offset) -> bool
[src]
fn ge(&self, other: &Offset) -> bool
[src]
impl Ord for Offset
[src]
fn cmp(&self, other: &Offset) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Offset> for Offset
[src]
impl From<(i32, i32)> for Offset
[src]
impl Copy for Offset
[src]
impl Hash for Offset
[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 Add<Offset> for Offset
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self::Output
[src]
impl Sub<Offset> for Offset
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self::Output
[src]
impl Mul<i32> for Offset
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, scalar: i32) -> Self::Output
[src]
impl Mul<Offset> for i32
[src]
type Output = Offset
The resulting type after applying the *
operator.
fn mul(self, vec: Offset) -> Self::Output
[src]
impl Debug for Offset
[src]
Auto Trait Implementations
impl Unpin for Offset
impl Sync for Offset
impl Send for Offset
impl UnwindSafe for Offset
impl RefUnwindSafe for Offset
Blanket Implementations
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, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,