Struct takuzu::Grid[][src]

pub struct Grid { /* fields omitted */ }

An opaque container for manipulating takuzu grids.

It provides the internal logic and other convenience functions. To create a Grid you can:

You can modify the cells as you like. Grids that break the rules will not be solved.

Implementations

impl Grid[src]

pub fn new(size: usize) -> Result<Self, GridSizeError>[src]

Creates an new empty grid of a given size.

Errors

Returns an error if the size is an odd number or 0.

pub fn size(&self) -> usize[src]

Returns the number of rows/columns of the array.

pub fn as_slice(&self) -> &[Cell][src]

Extracts a slice containing the entire underlying array.

pub fn as_mut_slice(&mut self) -> &mut [Cell][src]

Extracts a mutable slice of the entire underlying array.

pub fn is_filled(&self) -> bool[src]

Returns true if the grid contains no Empty cell.

Verifies that the grid does not currently violate any of the rules.

Returns true if the grid is legal.

Verifies that a certain cell does not violate any of the rules.

Returns true if the value is legal.

pub fn next_empty(&self) -> Option<(usize, usize)>[src]

Returns the coordinates of the first Empty cell or None if the grid is filled.

pub fn solve(&self) -> Result<Vec<Self>, GridError>[src]

Solves the grid using both rules logic and a backtracking algorithm.

Returns an array containing the solution(s), or an empty array if there are none.

Errors

Returns an error before any attempt at solving if the grid breaks any of the rules (i.e. if is_legal returns false).

Trait Implementations

impl Clone for Grid[src]

impl Debug for Grid[src]

impl Display for Grid[src]

impl Eq for Grid[src]

impl FromStr for Grid[src]

type Err = GridParseError

The associated error which can be returned from parsing.

impl Hash for Grid[src]

impl Index<(usize, usize)> for Grid[src]

type Output = Cell

The returned type after indexing.

impl IndexMut<(usize, usize)> for Grid[src]

impl PartialEq<Grid> for Grid[src]

impl StructuralEq for Grid[src]

impl StructuralPartialEq for Grid[src]

Auto Trait Implementations

impl RefUnwindSafe for Grid

impl Send for Grid

impl Sync for Grid

impl Unpin for Grid

impl UnwindSafe for Grid

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.