pub struct Stage(/* private fields */);Expand description
A newtype over u8 that represents a stage. All Stages must contain at least one
Bell; zero-bell Stages cannot be created without using incorrect unsafe code.
To create a new Stage, you can either create it directly with Stage::try_from (which
returns a Result) or with Stage::new (which panics if passed 0).
If you want a specific small Stage, then you can use the constants for the human name for
each Stage:
use bellframe::Stage;
// Converting from numbers is the same as using the constants
assert_eq!(Stage::SINGLES, Stage::new(3));
assert_eq!(Stage::MAJOR, Stage::new(8));
assert_eq!(Stage::CINQUES, Stage::new(11));
assert_eq!(Stage::SIXTEEN, Stage::new(16));
// We can use `Stage::from` to generate `Stage`s that don't have names
assert_eq!(Stage::new(100).num_bells(), 100);
assert_eq!(Stage::new(254).num_bells(), 254);Stages with human-friendly names are Displayed as their names:
assert_eq!(Stage::MAXIMUS.to_string(), "Maximus");
assert_eq!(Stage::new(9).to_string(), "Caters");
assert_eq!(Stage::new(50).to_string(), "50 bells");Implementations§
Source§impl Stage
impl Stage
Sourcepub fn num_bells_u8(self) -> u8
pub fn num_bells_u8(self) -> u8
Sourcepub fn bells(self) -> impl DoubleEndedIterator<Item = Bell>
pub fn bells(self) -> impl DoubleEndedIterator<Item = Bell>
Sourcepub fn contains(self, bell: Bell) -> bool
pub fn contains(self, bell: Bell) -> bool
Returns true if a given Bell is contained in this Stage.
Sourcepub fn from_lower_case_name(name: &str) -> Option<Stage>
pub fn from_lower_case_name(name: &str) -> Option<Stage>
Creates a Stage from the lower case version of the human-friendly name (e.g.
"royal", "triples" or "twenty-two").
pub fn checked_add(self, rhs: u8) -> Option<Self>
pub fn checked_sub(self, rhs: u8) -> Option<Self>
Sourcepub fn extent(self) -> SameStageVec
pub fn extent(self) -> SameStageVec
Returns a SameStageVec containing one copy of every Row possible in this Stage
in some arbitrary order.
Source§impl Stage
User-friendly constants for commonly used Stages.
impl Stage
User-friendly constants for commonly used Stages.
§Example
use bellframe::Stage;
assert_eq!(Stage::MINIMUS, Stage::new(4));
assert_eq!(Stage::MINOR, Stage::new(6));
assert_eq!(Stage::TRIPLES, Stage::new(7));
assert_eq!(Stage::FOURTEEN, Stage::new(14));
assert_eq!(Stage::SEPTUPLES, Stage::new(15));Trait Implementations§
Source§impl Ord for Stage
impl Ord for Stage
Source§impl PartialOrd for Stage
impl PartialOrd for Stage
impl Copy for Stage
impl Eq for Stage
impl StructuralPartialEq for Stage
Auto Trait Implementations§
impl Freeze for Stage
impl RefUnwindSafe for Stage
impl Send for Stage
impl Sync for Stage
impl Unpin for Stage
impl UnwindSafe for Stage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more