[−][src]Struct ingrid::Coordinate
A two-dimensional coordinate
This structure defines a basic two-dimensional coordinate to index grids. It
enables copy semantics to avoid handling ownership and references
throughout your code for no significant performance. Also, in practice, you
use the coord!
macro helper to instantiate coordinates.
Examples
// Create a coordinate to index the top-left element of a grid. let mut coord1 = coord!(0, 0); // Copy the coordinate into another variable. let coord2 = coord1; // The first variable is still accessible. coord1.x = 42; coord1.y += 1; // Additionally, you could also type the following. let coord3 = Coordinate::zero();
Fields
x: usize
The coordinate on the X axis.
y: usize
The coordinate on the Y axis.
Methods
impl Coordinate
[src]
pub fn new(x: usize, y: usize) -> Coordinate
[src]
Construct a new coordinate.
This function constructs a new coordinate from given X and Y values.
Examples
let coord = Coordinate::new(0, 42); assert_eq!(coord.x, 0); assert_eq!(coord.y, 42);
pub fn zero() -> Coordinate
[src]
Construct a zero coordinate.
This function constructs a 'zero' coordinate which is a coordinate with
both x
and y
values set at 0
.
Examples
let coord = Coordinate::zero(); assert_eq!(coord.x, 0); assert_eq!(coord.y, 0);
Trait Implementations
impl Clone for Coordinate
[src]
fn clone(&self) -> Coordinate
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Coordinate
[src]
impl Debug for Coordinate
[src]
impl Eq for Coordinate
[src]
impl<T> Index<Coordinate> for Grid<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, coordinate: Coordinate) -> &Self::Output
[src]
impl<T> IndexMut<Coordinate> for Grid<T>
[src]
fn index_mut(&mut self, coordinate: Coordinate) -> &mut Self::Output
[src]
impl PartialEq<Coordinate> for Coordinate
[src]
fn eq(&self, other: &Coordinate) -> bool
[src]
fn ne(&self, other: &Coordinate) -> bool
[src]
impl StructuralEq for Coordinate
[src]
impl StructuralPartialEq for Coordinate
[src]
Auto Trait Implementations
impl RefUnwindSafe for Coordinate
impl Send for Coordinate
impl Sync for Coordinate
impl Unpin for Coordinate
impl UnwindSafe for Coordinate
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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> 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>,