pub struct PackageCounts(/* private fields */);Expand description
Counts of packages by PackageState, backed by a fixed-size
array indexed by variant position. Bob has a variety of counter displays,
and this ensures they are all consistent.
§Examples
use bob::pkgstate::{PackageCounts, PackageState};
let mut counts = PackageCounts::default();
counts.add(PackageState::Success);
counts.add(PackageState::UpToDate);
counts.add(PackageState::Failed);
assert_eq!(counts[PackageState::Success], 1);
assert_eq!(counts.count(PackageState::is_success), 2);Implementations§
Source§impl PackageCounts
impl PackageCounts
Sourcepub fn add(&mut self, state: PackageState)
pub fn add(&mut self, state: PackageState)
Increment the counter for this state.
§Examples
use bob::pkgstate::{PackageCounts, PackageState};
let mut counts = PackageCounts::default();
counts.add(PackageState::Success);
assert_eq!(counts[PackageState::Success], 1);Sourcepub fn count(&self, pred: impl Fn(PackageState) -> bool) -> usize
pub fn count(&self, pred: impl Fn(PackageState) -> bool) -> usize
Sum the counts of all states matching the predicate.
§Examples
use bob::pkgstate::{PackageCounts, PackageState};
let mut counts = PackageCounts::default();
counts.add(PackageState::Success);
counts.add(PackageState::UpToDate);
assert_eq!(counts.count(PackageState::is_success), 2);Sourcepub fn successful(&self) -> usize
pub fn successful(&self) -> usize
Count of successful packages (freshly built or already up-to-date).
Trait Implementations§
Source§impl Clone for PackageCounts
impl Clone for PackageCounts
Source§fn clone(&self) -> PackageCounts
fn clone(&self) -> PackageCounts
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 PackageCounts
impl Debug for PackageCounts
Source§impl Default for PackageCounts
impl Default for PackageCounts
Source§impl Index<PackageState> for PackageCounts
impl Index<PackageState> for PackageCounts
Auto Trait Implementations§
impl Freeze for PackageCounts
impl RefUnwindSafe for PackageCounts
impl Send for PackageCounts
impl Sync for PackageCounts
impl Unpin for PackageCounts
impl UnsafeUnpin for PackageCounts
impl UnwindSafe for PackageCounts
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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