pub struct Counter(pub usize);Expand description
A Collection that only counts the final size of a set operation.
It is meant to be used to avoid unecessary allocations.
use sdset::duo::OpBuilder;
use sdset::{SetOperation, Set, SetBuf, Counter};
let a = Set::new(&[1, 2, 4, 6, 7])?;
let b = Set::new(&[2, 3, 4, 5, 6, 7])?;
let op = OpBuilder::new(a, b).union();
let mut counter = Counter::default();
SetOperation::<i32>::extend_collection(op, &mut counter);
assert_eq!(counter.0, 7);Tuple Fields§
§0: usizeImplementations§
Trait Implementations§
Source§impl<T> Collection<T> for Counter
impl<T> Collection<T> for Counter
Source§fn extend_from_slice(&mut self, elems: &[T])where
T: Clone,
fn extend_from_slice(&mut self, elems: &[T])where
T: Clone,
Extend the collection by cloning the elements.
Source§fn extend<I>(&mut self, elems: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, elems: I)where
I: IntoIterator<Item = T>,
Extend the collection by inserting the elements from the given
Iterator.Auto Trait Implementations§
impl Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnwindSafe for Counter
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