[][src]Struct world_map_gen::board::Board

pub struct Board<'a> { /* fields omitted */ }

A struct to represent a one world map. It is generally created by gen module's random map generator. This struct is JSON serializable with serde_json.

Methods

impl<'a> Board<'a>[src]

pub fn build<F>(width: usize, height: usize, builder: F) -> Board<'a> where
    F: FnMut(usize, usize) -> Land<'a>, 
[src]

Builds a board with given width * height cells. The builder generates a cell at the given position (x, y) by returning land::Land instance. Note that you can use land::LandKind::preset() to utilize a preset land instance easily.

pub fn width(&self) -> usize[src]

Returns number of cells per row

pub fn height(&self) -> usize[src]

Returns number of rows

pub fn at(&self, x: usize, y: usize) -> &Land[src]

Returns a reference to cell at given (x, y) position

pub fn at_mut(&mut self, x: usize, y: usize) -> &'a mut Land[src]

Returns a mutable reference to cell at given (x, y) position

pub fn iter<'b>(&'b self) -> Iter<'b, Land<'a>>[src]

Returns an iterator which iterates all cells from left-top corner to right-bottom corner

pub fn iter_mut<'b>(&'b mut self) -> IterMut<'b, Land<'a>>[src]

Returns a mutable reference iterator which iterates all cells from left-top corner to right bottom corner

pub fn rows<'b>(&'b self) -> Chunks<'b, Land<'a>>[src]

Returns an iterator which iterates each row as slice from top to bottom

pub fn rows_mut<'b>(&'b mut self) -> ChunksMut<'b, Land<'a>>[src]

Returns a mutable reference iterator which iterates each row as slice from top to bottom

Trait Implementations

impl<'a> PartialEq<Board<'a>> for Board<'a>[src]

impl<'a> Debug for Board<'a>[src]

impl<'a> Index<Pos> for Board<'a>[src]

type Output = Land<'a>

The returned type after indexing.

fn index(&self, p: Pos) -> &Land<'a>[src]

Returns a reference to cell at given position

impl<'a> IndexMut<Pos> for Board<'a>[src]

fn index_mut(&mut self, p: Pos) -> &mut Land<'a>[src]

Returns a mutable reference to cell at given position

impl<'a> Serialize for Board<'a>[src]

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>[src]

Serialize board in a map which contain width, height, cells as array, and legends for each land kind as map. By serde_json, the struct can be serialized to JSON object.

Auto Trait Implementations

impl<'a> Send for Board<'a>

impl<'a> Sync for Board<'a>

Blanket Implementations

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

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

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.

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

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

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