[][src]Struct gridly_adapters::Window

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

Grid adapter that views a subset of the wrapped grid, using the same coordinate system. For instance, given this grid:

OOOOO
OOOOO
OOOOO
OOOOO

A window with a root of (1, 1) and dimensions of (2, 2) will cover this region:

OOOOO
OXXOO
OXXOO
OOOOO

Example

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

let grid: VecGrid<i32> = VecGrid::new_row_major(
    Rows(4) + Columns(5),
    1..
).unwrap();

let grid = Window::new(
    grid,
    Row(1) + Column(1),
    Rows(2) + Columns(2),
);

assert_eq!(grid.get((0, 0)).ok(), None);
assert_eq!(grid.get((1, 1)).ok(), Some(&7));
assert_eq!(grid.get((2, 2)).ok(), Some(&13));
assert_eq!(grid.get((3, 3)).ok(), None);

Implementations

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

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

impl<G> Window<G>[src]

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

Trait Implementations

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

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

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

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

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

type Item = G::Item

The item type stored in the grid

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

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

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

Auto Trait Implementations

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

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

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

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

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