[−][src]Struct world_map_gen::board::Board
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]
F: FnMut(usize, usize) -> Land<'a>,
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]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,