pub struct Score(/* private fields */);Expand description
A SOLVE score: a finite value in 0.0..=10.0.
Implementations§
Source§impl Score
impl Score
Sourcepub fn new(value: f64) -> Result<Self, SolveError>
pub fn new(value: f64) -> Result<Self, SolveError>
Constructs a score, rejecting non-finite values and values outside 0.0..=10.0.
§Errors
Returns SolveError::NotFinite or SolveError::OutOfRange.
Sourcepub const fn lit(value: f64) -> Self
pub const fn lit(value: f64) -> Self
Constructs a score from a literal, panicking if it is out of range.
§Panics
Panics if value is not within 0.0..=10.0. Usable in const context, so an
invalid literal fails at compile time.
Sourcepub fn rounded(self) -> Self
pub fn rounded(self) -> Self
Rounds to one decimal place, as the specification does for component totals.
Sourcepub fn level(self) -> Level
pub fn level(self) -> Level
The difficulty band this score falls in.
Bands are half-open ([0,4), [4,7), [7,9), [9,10]), which reproduces the
specification’s 0.0–3.9 / 4.0–6.9 / 7.0–8.9 / 9.0–10.0 bands for values already
rounded to one decimal. Call Score::rounded first if you want band assignment to
agree with a rounded published figure.
Trait Implementations§
impl Copy for Score
impl Eq for Score
Source§impl From<AttackSurface> for Score
impl From<AttackSurface> for Score
Source§fn from(anchor: AttackSurface) -> Self
fn from(anchor: AttackSurface) -> Self
Converts to this type from the input type.
Source§impl From<ExpertLevel> for Score
impl From<ExpertLevel> for Score
Source§fn from(anchor: ExpertLevel) -> Self
fn from(anchor: ExpertLevel) -> Self
Converts to this type from the input type.
Source§impl From<Readability> for Score
impl From<Readability> for Score
Source§fn from(anchor: Readability) -> Self
fn from(anchor: Readability) -> Self
Converts to this type from the input type.
Source§impl Ord for Score
impl Ord for Score
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Score
impl PartialOrd for Score
impl StructuralPartialEq for Score
Auto Trait Implementations§
impl Freeze for Score
impl RefUnwindSafe for Score
impl Send for Score
impl Sync for Score
impl Unpin for Score
impl UnsafeUnpin for Score
impl UnwindSafe for Score
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more