[][src]Struct sweeper::ClearingMut

pub struct ClearingMut<'f> { /* fields omitted */ }

A mutable reference to a clearing on the specified field.

This is merely a mutable reference to the area on a field which is known to be clear land. Nothing is owned by this structure.

Methods

impl<'f> ClearingMut<'f>[src]

pub fn new(
    field: &'f mut Field,
    anchor_location: FieldCoordinates
) -> Option<Self>
[src]

Returns a ClearingMut on the specified Field, or None if the location has 1 or more neighboring mines or is out of bounds.

pub fn field(self) -> &'f Field[src]

Returns the field on which this clearing is located.

pub fn anchor_location(self) -> FieldCoordinates[src]

Returns the location around which this clearing is formed.

This can be any location inside the clearing. More specifically, the one used during creation is returned.

pub fn for_every_tile<F>(self, include_shore: bool, f: F) where
    F: FnMut(&'f Field, FieldCoordinates), 
[src]

Executes the specified closure on every tile inside the clearing. Optionally can include the "shore" (tiles with numbers) as a part of the clearing.

The closure takes an immutable reference to the field as the first argument and the location of the tile as the second one. No return value is expected.

This is a version of for_every_tile_mut which doesn't allow mutating the field.

pub fn for_every_tile_mut<F>(self, include_shore: bool, f: F) where
    F: FnMut(&mut Field, FieldCoordinates), 
[src]

Executes the specified closure on every tile inside the clearing. Optionally can include the "shore" (tiles with numbers) as a part of the clearing.

The closure takes a mutable reference to the field as the first argument and the location of the tile as the second one. No return value is expected.

#[must_use = "fully traversing a clearing is an expensive operation involving memory allocation"]pub fn size(self, include_shore: bool) -> NonZeroUsize[src]

Returns the size of the clearing, in tiles. Optionally can include the "shore" (tiles with numbers) as a part of the clearing.

Use open instead if you want to open the clearing afterwards, since it provides the size itself.

#[must_use = "fully traversing a clearing is an expensive operation involving memory allocation"]pub fn includes(
    self,
    coordinates: FieldCoordinates,
    include_shore: bool
) -> bool
[src]

Returns true if the given tile is inside the clearing, false otherwise. Optionally can include the "shore" (tiles with numbers) as a part of the clearing.

pub fn open(self, include_shore: bool) -> (usize, NonZeroUsize)[src]

Fully opens the clearing on the field and returns the amount of tiles opened. Optionally can include the "shore" (tiles with numbers) as a part of the clearing.

The first number is the amount of tiles which were opened, and the second one is the total size of the clearing, which includes both previously closed and previously open tiles.

Trait Implementations

impl<'f> From<ClearingMut<'f>> for Clearing<'f>[src]

Auto Trait Implementations

impl<'f> RefUnwindSafe for ClearingMut<'f>

impl<'f> Send for ClearingMut<'f>

impl<'f> Sync for ClearingMut<'f>

impl<'f> Unpin for ClearingMut<'f>

impl<'f> !UnwindSafe for ClearingMut<'f>

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, 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<V, T> VZip<V> for T where
    V: MultiLane<T>,