[−][src]Struct ingrid::Offset
A two-dimensional offset
This structure defines a basic two-dimensional offset to shift values
during some operations on grid. It enables copy semantics to avoid handling
ownership and references throughout your code for no significant
performance. Also, in practice, you use the offset!
macro helper to
instantiate offsets; this is to be consistent with the use of coordinates.
Examples
// Create a size to shift the elements of a grid. let mut offset1 = offset!(-1, 1); // Copy the offset into another variable. let offset2 = offset1; // The first variable is still accessible. offset1.x = 1; offset1.y = -1; // Additionally, you could also type the following. let offset3 = Offset::zero();
Fields
x: isize
The offset value on the X axis.
y: isize
The offset value on the Y axis.
Methods
impl Offset
[src]
pub fn new(x: isize, y: isize) -> Offset
[src]
Construct a new offset.
This function constructs a new offset from given X and Y values.
Examples
let offset = Offset::new(-1, 1); assert_eq!(offset.x, -1); assert_eq!(offset.y, 1);
pub fn zero() -> Offset
[src]
Construct a zero offset.
This function constructs a 'zero' offset which is a offset with both x
and y
values set at 0
.
Examples
let offset = Offset::zero(); assert_eq!(offset.x, 0); assert_eq!(offset.y, 0);
Trait Implementations
impl Clone for Offset
[src]
impl Copy for Offset
[src]
impl Debug for Offset
[src]
impl Eq for Offset
[src]
impl PartialEq<Offset> for Offset
[src]
impl StructuralEq for Offset
[src]
impl StructuralPartialEq for Offset
[src]
Auto Trait Implementations
impl RefUnwindSafe for Offset
impl Send for Offset
impl Sync for Offset
impl Unpin for Offset
impl UnwindSafe for Offset
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>,