diff --git a/src/fallible.rs b/src/fallible.rs index dc7ddd7..1f3e981 100644 --- a/src/fallible.rs +++ b/src/fallible.rs @@ -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. diff --git a/src/lib.rs b/src/lib.rs index 006b7e6..9d809da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { Iter { rest: self } @@ -808,7 +824,7 @@ impl IntoIterator for BitFlags { } } -/// Iterator that yields each set flag. +/// Iterator that yields each flag set in a `BitFlags`. #[derive(Clone, Debug)] pub struct Iter { rest: BitFlags,