Struct tinyset::setusize::SetUsize [−][src]
pub struct SetUsize(_);
Expand description
A set for usize elements.
Implementations
Create an empty set with capacity to hold the provided set.
use tinyset::SetUsize;
let a: SetUsize = (1..300).collect();
let mut b = SetUsize::with_capacity_of(&a);
assert_eq!(a.capacity(), b.capacity());
assert_eq!(b.len(), 0);
for i in a.iter() {
b.insert(i);
}
assert_eq!(a.capacity(), b.capacity());
assert_eq!(b.len(), a.len());
Create an empty set with capacity to hold the provided set.
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
Removes an element, and returns true if that element was present.
Trait Implementations
Returns the union of self
and rhs
as a new SetUsize
.
Examples
let a: tinyset::SetUsize = (1..4).collect();
let b: tinyset::SetUsize = (3..6).collect();
assert_eq!(&a | &b, (1..6).collect());
Returns the union of self
and rhs
as a new SetUsize
, consuming self
.
Examples
let a: tinyset::SetUsize = (1..4).collect();
let b: tinyset::SetUsize = (3..6).collect();
assert_eq!(a | &b, (1..6).collect());
Creates a value from an iterator. Read more
Returns the difference of self
and rhs
as a new SetUsize
.
Examples
let a: tinyset::SetUsize = (1..4).collect();
let b: tinyset::SetUsize = (3..6).into_iter().collect();
assert_eq!(&a - &b, (1..3).collect());
Returns the difference of self
and rhs
as a new SetUsize
consuming self
. Should not allocate.
Examples
let a: tinyset::SetUsize = (1..4).collect();
let b: tinyset::SetUsize = (3..6).into_iter().collect();
assert_eq!(a - &b, (1..3).collect());
Auto Trait Implementations
impl RefUnwindSafe for SetUsize
impl UnwindSafe for SetUsize
Blanket Implementations
Mutably borrows from an owned value. Read more