[−][src]Enum sudoku_backend::ops::BoardDifficulty
The difficulties sudoku boards can come in.
Consult doc/sudoku.md
Variants
EasyMediumHardMethods
impl BoardDifficulty[src]
impl BoardDifficultypub fn score(&self, solve_time: &Duration) -> Option<u64>[src]
pub fn score(&self, solve_time: &Duration) -> Option<u64>Calculate the score for a board according to doc/sudoku.md#scoring-formula
Negative duration is out of domain and will return None.
Examples
assert_eq!(BoardDifficulty::Easy.score(&Duration::seconds(120)), Some(55)); assert_eq!(BoardDifficulty::Hard.score(&Duration::seconds(250)), Some(126)); assert_eq!(BoardDifficulty::Medium.score(&Duration::seconds(-65)), None);
pub fn from_numeric(repr: u64) -> Option<BoardDifficulty>[src]
pub fn from_numeric(repr: u64) -> Option<BoardDifficulty>Parse a numerical representation of the difficulty.
Guaranteed to validly round-trip through to_numeric().
Examples
assert_eq!(BoardDifficulty::from_numeric(1), Some(BoardDifficulty::Easy)); assert_eq!(BoardDifficulty::from_numeric(2), Some(BoardDifficulty::Medium)); assert_eq!(BoardDifficulty::from_numeric(3), Some(BoardDifficulty::Hard)); assert_eq!(BoardDifficulty::from_numeric(0), None); assert_eq!(BoardDifficulty::from_numeric(4), None); assert_eq!(BoardDifficulty::from_numeric(25), None);
pub fn to_numeric(&self) -> u64[src]
pub fn to_numeric(&self) -> u64Convert difficulty to a numeric repr
Guaranteed to validly round-trip through from_numeric().
Examples
assert_eq!(BoardDifficulty::Easy.to_numeric(), 1); assert_eq!(BoardDifficulty::Medium.to_numeric(), 2); assert_eq!(BoardDifficulty::Hard.to_numeric(), 3); assert_eq!(BoardDifficulty::from_numeric(BoardDifficulty::Easy.to_numeric()), Some(BoardDifficulty::Easy));
pub fn additional_squares(&self) -> usize[src]
pub fn additional_squares(&self) -> usizeHow many more squares to compensate difficulty with.
A good approximation of Sudoku difficulty is square sparsity, so to make a board easier one can simply add more squares to the default unique solution.
Examples
assert_eq!(BoardDifficulty::Easy.additional_squares(), 22); assert_eq!(BoardDifficulty::Medium.additional_squares(), 11); assert_eq!(BoardDifficulty::Hard.additional_squares(), 0);
Trait Implementations
impl PartialEq<BoardDifficulty> for BoardDifficulty[src]
impl PartialEq<BoardDifficulty> for BoardDifficultyfn eq(&self, other: &BoardDifficulty) -> bool[src]
fn eq(&self, other: &BoardDifficulty) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl Clone for BoardDifficulty[src]
impl Clone for BoardDifficultyfn clone(&self) -> BoardDifficulty[src]
fn clone(&self) -> BoardDifficultyfn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for BoardDifficulty[src]
impl Copy for BoardDifficultyimpl Ord for BoardDifficulty[src]
impl Ord for BoardDifficultyfn cmp(&self, other: &BoardDifficulty) -> Ordering[src]
fn cmp(&self, other: &BoardDifficulty) -> Orderingfn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl Eq for BoardDifficulty[src]
impl Eq for BoardDifficultyimpl PartialOrd<BoardDifficulty> for BoardDifficulty[src]
impl PartialOrd<BoardDifficulty> for BoardDifficultyfn partial_cmp(&self, other: &BoardDifficulty) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &BoardDifficulty) -> Option<Ordering>#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Debug for BoardDifficulty[src]
impl Debug for BoardDifficultyimpl Hash for BoardDifficulty[src]
impl Hash for BoardDifficultyfn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl Serialize for BoardDifficulty[src]
impl Serialize for BoardDifficultyfn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, impl<'de> Deserialize<'de> for BoardDifficulty[src]
impl<'de> Deserialize<'de> for BoardDifficultyfn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, impl<'v> FromFormValue<'v> for BoardDifficulty[src]
impl<'v> FromFormValue<'v> for BoardDifficultytype Error = Option<String>
The associated error which can be returned from parsing. It is a good idea to have the return type be or contain an &'v str so that the unparseable string can be examined after a bad parse. Read more
fn from_form_value(form_value: &'v RawStr) -> Result<Self, Self::Error>[src]
fn from_form_value(form_value: &'v RawStr) -> Result<Self, Self::Error>fn default() -> Option<Self>[src]
fn default() -> Option<Self>Returns a default value to be used when the form field does not exist. If this returns None, then the field is required. Otherwise, this should return Some(default_value). The default implementation simply returns None. Read more
Auto Trait Implementations
impl Send for BoardDifficulty
impl Send for BoardDifficultyimpl Sync for BoardDifficulty
impl Sync for BoardDifficultyBlanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeIdimpl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut Timpl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, impl<T> Typeable for T where
T: Any, [src]
impl<T> Typeable for T where
T: Any, impl<T> IntoSql for T[src]
impl<T> IntoSql for Tfn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>, [src]
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>, Convert self to an expression for Diesel's query builder. Read more
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>, [src]
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>, Convert &self to an expression for Diesel's query builder. Read more