pub struct TotalCount(/* private fields */);Expand description
Total count newtype
Poka-Yoke: Use this newtype instead of usize to prevent count errors.
Ensures total count is always >= 0 and >= covered count.
§Example
use chicago_tdd_tools::coverage::{TotalCount, CoveredCount};
let total = TotalCount::new(100).unwrap();
let covered = CoveredCount::new(80).unwrap();
// Validate: covered <= total
assert!(covered.get() <= total.get());
assert_eq!(total.get(), 100);
assert_eq!(covered.get(), 80);Implementations§
Source§impl TotalCount
impl TotalCount
Sourcepub const ZERO: Self
pub const ZERO: Self
Zero total count constant
Poka-Yoke: Infallible constructor - no Option wrapping needed.
Use this instead of TotalCount::new(0).unwrap().
Sourcepub const fn new(value: usize) -> Option<Self>
pub const fn new(value: usize) -> Option<Self>
Create a new total count (legacy API - prefer from_usize)
Note: This always returns Some. For infallible construction, use from_usize().
Sourcepub const fn from_usize(value: usize) -> Self
pub const fn from_usize(value: usize) -> Self
Create a new total count (infallible)
Poka-Yoke: Infallible constructor - use this instead of .new().unwrap().
Any usize value is valid for total count.
Sourcepub const fn into_usize(self) -> usize
pub const fn into_usize(self) -> usize
Convert to usize
Trait Implementations§
Source§impl Clone for TotalCount
impl Clone for TotalCount
Source§fn clone(&self) -> TotalCount
fn clone(&self) -> TotalCount
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TotalCount
impl Debug for TotalCount
Source§impl From<TotalCount> for usize
impl From<TotalCount> for usize
Source§fn from(count: TotalCount) -> Self
fn from(count: TotalCount) -> Self
Converts to this type from the input type.
Source§impl Hash for TotalCount
impl Hash for TotalCount
Source§impl Ord for TotalCount
impl Ord for TotalCount
Source§fn cmp(&self, other: &TotalCount) -> Ordering
fn cmp(&self, other: &TotalCount) -> Ordering
1.21.0 · 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
Source§impl PartialEq for TotalCount
impl PartialEq for TotalCount
Source§impl PartialOrd for TotalCount
impl PartialOrd for TotalCount
impl Copy for TotalCount
impl Eq for TotalCount
impl StructuralPartialEq for TotalCount
Auto Trait Implementations§
impl Freeze for TotalCount
impl RefUnwindSafe for TotalCount
impl Send for TotalCount
impl Sync for TotalCount
impl Unpin for TotalCount
impl UnwindSafe for TotalCount
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