[][src]Struct gridly_adapters::ZeroRoot

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

Grid adapter that translates the locations of the wrapped grid such that the root is always (0, 0). Useful when combined with Window.

Example

use gridly_grids::SparseGrid;
use gridly_adapters::ZeroRoot;
use gridly::prelude::*;

let mut grid: SparseGrid<i32> = SparseGrid::new_rooted(Row(1) + Column(1), Rows(3) + Columns(4));
grid.set(Row(1) + Column(2), 4).unwrap();
grid.set(Row(2) + Column(3), 5).unwrap();

let grid = ZeroRoot::new(grid);

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

assert_eq!(grid.get((3, 4)).ok(), None);

Implementations

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

pub fn new(grid: G) -> Self[src]

impl<G> ZeroRoot<G>[src]

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

Trait Implementations

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

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

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

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

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

type Item = G::Item

The item type stored in the grid

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

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

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

Auto Trait Implementations

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

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

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

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

impl<G> UnwindSafe for ZeroRoot<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.