SquareBoardBuilder

Struct SquareBoardBuilder 

Source
pub struct SquareBoardBuilder { /* private fields */ }
Expand description

A builder for boards with square-shaped cells, i.e. the rectangular boards found in Numberlink puzzles and in Flow Free and the Bridges and Warps expansions.

Implementations§

Source§

impl SquareBoardBuilder

Source

pub fn add_warp( &mut self, location: Location, direction: Option<SquareStep>, ) -> &mut Self

Add a warp at the specified location pointing in direction. A warp is located on one edge of the board and connects one cell to its partner on the opposite edge of the board along a cardinal direction.

Specifying direction necessary if and only if location is at a corner, in which case the direction is ambiguous. If location is on an edge but not at a corner, direction is ignored regardless of whether it is specified.

May cause the builder to enter a FeatureOutOfBounds invalid state if location is out of bounds or not on an edge. May cause the builder to enter a WarpBadDirection invalid state if location is at a corner and direction is missing or is impossible for a warp at this location. If the builder is already in an invalid state, this function does nothing.

Trait Implementations§

Source§

impl Builder<SquareStep> for SquareBoardBuilder

Source§

fn with_dims(dims: (NonZero<usize>, NonZero<usize>)) -> Self

Construct a new Self with the specified dimensions, specified in (x, y) order.
Source§

fn add_termini( &mut self, display: char, locations: (Location, Location), ) -> &mut Self

Add termini or “flow endpoints”. The order in which locations are specified does not matter. Read more
Source§

fn pop_termini(&mut self) -> &mut Self

Remove the most recently added pair of termini. Read more
Source§

fn add_bridge(&mut self, location: Location) -> &mut Self

Add a bridge at the specified location. Read more
Source§

fn drop_location(&mut self, location: Location) -> &mut Self

Drop a location from the board. Any feature here, such as a bridge, warp, or terminus, will be deleted regardless of where in the chain this method is called. Keep in mind this may cause the board to become unsolvable. Read more
Source§

fn disconnect(&mut self, locations: UnorderedPair<Location>) -> &mut Self

Disconnect the two locations, i.e. place a wall between them. Read more
Source§

fn disconnect_around( &mut self, location: Location, directions: &Vec<SquareStep>, ) -> &mut Self

Shorthand for multiple calls to Self::disconnect, with the same conditions. Read more
Source§

fn is_valid(&self) -> Option<&[BuilderInvalidReason]>

Check the validity of this builder, ensuring no BuilderInvalidReason condition has arisen. Read more
Source§

fn build(&self) -> Result<Board<SquareStep>, &[BuilderInvalidReason]>

Convert the state of this builder into a Board. If the builder is invalid for any reason, a reference to a Vec of BuilderInvalidReason will indicate why.
Source§

impl Clone for SquareBoardBuilder

Source§

fn clone(&self) -> SquareBoardBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SquareBoardBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Reference, Outer, OuterFieldType, Inner> HasPart<Nested<Outer, Inner>> for Reference
where Reference: HasPart<Outer> + ?Sized, Outer: Part<PartType = Field<OuterFieldType>>, Inner: Part, OuterFieldType: HasPart<Inner, RawTarget = OuterFieldType> + PartialRefTarget + ?Sized,

Source§

unsafe fn part_ptr( ptr: *const <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::Ptr

Given a constant pointer to a target, produce a constant pointer to a part of it. Read more
Source§

unsafe fn part_ptr_mut( ptr: *mut <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::PtrMut

Given a mutable pointer to a target, produce a mutable pointer to a part of it. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.