[][src]Struct gridly_adapters::Translate

pub struct Translate<G> { /* fields omitted */ }

Grid adapter that translates the locations of the wrapped grid. The translation is added to the inner grid location; that is, if the inner grid has a root at (0, 0), and the translation is (2, 3), the new root will be (2, 3).

Example

use gridly_grids::VecGrid;
use gridly_adapters::Translate;
use gridly::prelude::*;

let grid: VecGrid<i32> = VecGrid::new_row_major(
    Rows(2) + Columns(2),
    [1, 2, 3, 4].iter().copied()
).unwrap();

let grid = Translate::new(grid, Rows(2) + Columns(3));

assert_eq!(grid.get((2, 3)).ok(), Some(&1));
assert_eq!(grid.get((2, 4)).ok(), Some(&2));
assert_eq!(grid.get((3, 3)).ok(), Some(&3));
assert_eq!(grid.get((3, 4)).ok(), Some(&4));

assert_eq!(grid.get((0, 0)).ok(), None);

Implementations

impl<G: GridBounds> Translate<G>[src]

pub fn new(grid: G, translation: impl VectorLike) -> Self[src]

impl<G> Translate<G>[src]

pub fn into_inner(self) -> G[src]

pub fn translation(&self) -> Vector[src]

Trait Implementations

impl<G> AsMut<G> for Translate<G>[src]

impl<G> AsRef<G> for Translate<G>[src]

impl<G: Clone> Clone for Translate<G>[src]

impl<G: Debug> Debug for Translate<G>[src]

impl<G: Grid> Grid for Translate<G>[src]

type Item = G::Item

The item type stored in the grid

impl<G: GridBounds> GridBounds for Translate<G>[src]

impl<G: GridMut> GridMut for Translate<G>[src]

impl<G: GridSetter> GridSetter for Translate<G>[src]

Auto Trait Implementations

impl<G> RefUnwindSafe for Translate<G> where
    G: RefUnwindSafe

impl<G> Send for Translate<G> where
    G: Send

impl<G> Sync for Translate<G> where
    G: Sync

impl<G> Unpin for Translate<G> where
    G: Unpin

impl<G> UnwindSafe for Translate<G> where
    G: UnwindSafe

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.