Struct takuzu::Grid [−][src]
An opaque container for manipulating takuzu grids.
It provides the internal logic and other convenience functions.
To create a Grid
you can:
- create an empty one yourself with
Grid::new
. - use the
FromStr
trait, e.g. by callingparse
on a string.
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.
pub fn is_legal(&self) -> bool
[src]
Verifies that the grid does not currently violate any of the rules.
Returns true
if the grid is legal.
pub fn is_cell_legal(&self, coord: (usize, usize)) -> bool
[src]
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]
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.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Grid
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Index<(usize, usize)> for Grid
[src]
type Output = Cell
The returned type after indexing.
fn index(&self, (i, j): (usize, usize)) -> &Self::Output
[src]
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]
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,