Struct sudoku_variants::generator::Generator[][src]

pub struct Generator<R: Rng> { /* fields omitted */ }

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]

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 If block_width or block_height is invalid (zero).
  • SudokuError::UnsatisfiableConstraint If there are no grids with the given dimensions that match the provided constraint.

Auto Trait Implementations

impl<R> RefUnwindSafe for Generator<R> where
    R: RefUnwindSafe

impl<R> Send for Generator<R> where
    R: Send

impl<R> Sync for Generator<R> where
    R: Sync

impl<R> Unpin for Generator<R> where
    R: Unpin

impl<R> UnwindSafe for Generator<R> where
    R: UnwindSafe

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>,