Struct sudoku_variants::generator::Generator [−][src]
A generator randomly generates a full Sudoku, that is, a Sudoku with no missing digits. It uses a random number generator to decide the content. For most cases, sensible defaults are provided by Generator::new_default.
Implementations
impl Generator<ThreadRng>
[src]
pub fn new_default() -> Generator<ThreadRng>
[src]
Creates a new generator that uses a ThreadRng to generate the random digits.
impl<R: Rng> Generator<R>
[src]
pub fn new(rng: R) -> Generator<R>
[src]
Creates a new generator that uses the given random number generator to generate random digits.
pub fn generate<C: Constraint + Clone>(
&mut self,
block_width: usize,
block_height: usize,
constraint: C
) -> SudokuResult<Sudoku<C>>
[src]
&mut self,
block_width: usize,
block_height: usize,
constraint: C
) -> SudokuResult<Sudoku<C>>
Generates a new random Sudoku with all digits that matches the given parameters. If it is not possible, an error will be returned.
It is guaranteed that Sudoku::is_valid on the result returns true
.
Arguments
block_width
: The horizontal dimension of one sub-block of the grid. To ensure a square grid, this is also the number of blocks that compose the grid vertically. For an ordinary Sudoku grid, this is 3. Must be greater than 0.block_height
: The vertical dimension of one sub-block of the grid. To ensure a square grid, this is also the number of blocks that compose the grid horizontally. For an ordinary Sudoku grid, this is 3. Must be greater than 0.constraint
: The constraint which will be matched by the generated Sudoku, which will also be contained and checked by the output Sudoku.
Errors
SudokuError::InvalidDimensions
Ifblock_width
orblock_height
is invalid (zero).SudokuError::UnsatisfiableConstraint
If there are no grids with the given dimensions that match the providedconstraint
.
Auto Trait Implementations
impl<R> RefUnwindSafe for Generator<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for Generator<R> where
R: Send,
R: Send,
impl<R> Sync for Generator<R> where
R: Sync,
R: Sync,
impl<R> Unpin for Generator<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for Generator<R> where
R: UnwindSafe,
R: UnwindSafe,
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,
pub 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.
pub 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.
pub 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>,