Skip to content

Commit

Permalink
feat: Add must_use on all iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
GrayJack committed Nov 25, 2024
1 parent 88cdc71 commit 1e02209
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ impl fmt::Display for BitSetError {
///
/// let mut drain = a.drain();
/// ```
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Drain<'a, T: PrimInt + 'a, const N: usize> {
inner: &'a mut BitSet<T, N>,
}
Expand Down Expand Up @@ -1102,6 +1103,7 @@ impl<T: PrimInt, const N: usize> FusedIterator for Drain<'_, T, N> {}
/// ```
#[derive(Clone)]
#[repr(transparent)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct IntoIter<T, const N: usize>(BitSet<T, N>);

impl<T: PrimInt, const N: usize> fmt::Debug for IntoIter<T, N> {
Expand Down Expand Up @@ -1177,6 +1179,7 @@ impl<T: PrimInt, const N: usize> ExactSizeIterator for IntoIter<T, N> {
/// let mut iter = a.iter();
/// ```
#[derive(Clone)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Iter<'a, T, const N: usize> {
borrow: &'a BitSet<T, N>,
bit: usize,
Expand Down Expand Up @@ -1263,8 +1266,8 @@ impl<T: PrimInt, const N: usize> ExactSizeIterator for Iter<'_, T, N> {
///
/// let mut difference = a.difference(&b);
/// ```
#[must_use = "this returns the difference as an iterator, without modifying either input set"]
#[derive(Clone)]
#[must_use = "this returns the difference as an iterator, without modifying either input set"]
pub struct Difference<'a, T: PrimInt + 'a, U: PrimInt + 'a, const N: usize, const M: usize> {
// iterator of the first set
iter: Iter<'a, T, N>,
Expand Down Expand Up @@ -1328,8 +1331,8 @@ where
///
/// let mut intersection = a.intersection(&b);
/// ```
#[must_use = "this returns the intersection as an iterator, without modifying either input set"]
#[derive(Clone)]
#[must_use = "this returns the intersection as an iterator, without modifying either input set"]
pub struct Intersection<'a, T, U, const N: usize, const M: usize>
where
T: PrimInt + 'a,
Expand Down Expand Up @@ -1396,8 +1399,8 @@ where
///
/// let mut union_iter = a.union(&b);
/// ```
#[must_use = "this returns the union as an iterator, without modifying either input set"]
#[derive(Clone)]
#[must_use = "this returns the union as an iterator, without modifying either input set"]
pub struct Union<'a, T: PrimInt + 'a, U: PrimInt + 'a, const N: usize, const M: usize> {
iter: UnionChoose<'a, T, U, N, M>,
}
Expand Down Expand Up @@ -1488,8 +1491,8 @@ where
///
/// let mut intersection = a.symmetric_difference(&b);
/// ```
#[must_use = "this returns the difference as an iterator, without modifying either input set"]
#[derive(Clone)]
#[must_use = "this returns the difference as an iterator, without modifying either input set"]
pub struct SymmetricDifference<'a, T, U, const N: usize, const M: usize>
where
T: PrimInt + 'a,
Expand Down

0 comments on commit 1e02209

Please sign in to comment.