[−][src]Struct sweeper::ClearingMut
A mutable reference to a clearing on the specified field.
See the documentation for the [immutable version] for an explanation of what is a clearing and how this structure works.
Methods
impl<'f, Ct, Cf> ClearingMut<'f, Ct, Cf>
[src]
pub fn new(
field: &'f mut Field<Ct, Cf>,
anchor_location: FieldCoordinates
) -> Option<Self>
[src]
field: &'f mut Field<Ct, Cf>,
anchor_location: FieldCoordinates
) -> Option<Self>
Returns a ClearingMut
on the specified Field
, or None
if the location has 1 or more neighboring mines or is out of bounds.
pub const fn field(self) -> &'f Field<Ct, Cf>
[src]
Returns the field on which this clearing is located.
pub const 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<Ct, Cf>, FieldCoordinates),
[src]
F: FnMut(&'f Field<Ct, Cf>, FieldCoordinates),
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<Ct, Cf>, FieldCoordinates),
[src]
F: FnMut(&mut Field<Ct, Cf>, FieldCoordinates),
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]
self,
coordinates: FieldCoordinates,
include_shore: bool
) -> bool
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, Ct, Cf> From<ClearingMut<'f, Ct, Cf>> for Clearing<'f, Ct, Cf>
[src]
fn from(op: ClearingMut<'f, Ct, Cf>) -> Self
[src]
Auto Trait Implementations
impl<'f, Ct, Cf> RefUnwindSafe for ClearingMut<'f, Ct, Cf> where
Cf: RefUnwindSafe,
Ct: RefUnwindSafe,
Cf: RefUnwindSafe,
Ct: RefUnwindSafe,
impl<'f, Ct, Cf> Send for ClearingMut<'f, Ct, Cf> where
Cf: Send,
Ct: Send,
Cf: Send,
Ct: Send,
impl<'f, Ct, Cf> Sync for ClearingMut<'f, Ct, Cf> where
Cf: Sync,
Ct: Sync,
Cf: Sync,
Ct: Sync,
impl<'f, Ct, Cf> Unpin for ClearingMut<'f, Ct, Cf>
impl<'f, Ct, Cf> !UnwindSafe for ClearingMut<'f, Ct, Cf>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,