Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
meithecatte committed Feb 5, 2024
1 parent 7bee362 commit 76f8b87
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/fallible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ for_each_uint! { $ty $hide_docs =>
}

/// The error struct used by [`BitFlags::from_bits`]
/// and the [`TryFrom`] implementation`
/// for invalid values.
/// and the [`TryFrom`] implementation for invalid values.
///
/// Note that the implementation of [`std::error::Error`]
/// for this type is gated on the `std` feature flag.
Expand Down
20 changes: 18 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,23 @@ where
}
}

/// Returns an iterator that yields each set flag
/// Iterate over the `BitFlags`.
///
/// ```
/// # use enumflags2::{bitflags, make_bitflags};
/// # #[bitflags]
/// # #[derive(Clone, Copy, PartialEq, Debug)]
/// # #[repr(u8)]
/// # enum MyFlag {
/// # A = 1 << 0,
/// # B = 1 << 1,
/// # C = 1 << 2,
/// # }
/// let flags = make_bitflags!(MyFlag::{A | C});
///
/// flags.iter()
/// .for_each(|flag| println!("{:?}", flag));
/// ```
#[inline]
pub fn iter(self) -> Iter<T> {
Iter { rest: self }
Expand All @@ -808,7 +824,7 @@ impl<T: BitFlag> IntoIterator for BitFlags<T> {
}
}

/// Iterator that yields each set flag.
/// Iterator that yields each flag set in a `BitFlags`.
#[derive(Clone, Debug)]
pub struct Iter<T: BitFlag> {
rest: BitFlags<T>,
Expand Down

0 comments on commit 76f8b87

Please sign in to comment.