Skip to content

Commit 76f8b87

Browse files
committed
Documentation improvements
1 parent 7bee362 commit 76f8b87

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/fallible.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ for_each_uint! { $ty $hide_docs =>
1919
}
2020

2121
/// The error struct used by [`BitFlags::from_bits`]
22-
/// and the [`TryFrom`] implementation`
23-
/// for invalid values.
22+
/// and the [`TryFrom`] implementation for invalid values.
2423
///
2524
/// Note that the implementation of [`std::error::Error`]
2625
/// for this type is gated on the `std` feature flag.

src/lib.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,23 @@ where
792792
}
793793
}
794794

795-
/// Returns an iterator that yields each set flag
795+
/// Iterate over the `BitFlags`.
796+
///
797+
/// ```
798+
/// # use enumflags2::{bitflags, make_bitflags};
799+
/// # #[bitflags]
800+
/// # #[derive(Clone, Copy, PartialEq, Debug)]
801+
/// # #[repr(u8)]
802+
/// # enum MyFlag {
803+
/// # A = 1 << 0,
804+
/// # B = 1 << 1,
805+
/// # C = 1 << 2,
806+
/// # }
807+
/// let flags = make_bitflags!(MyFlag::{A | C});
808+
///
809+
/// flags.iter()
810+
/// .for_each(|flag| println!("{:?}", flag));
811+
/// ```
796812
#[inline]
797813
pub fn iter(self) -> Iter<T> {
798814
Iter { rest: self }
@@ -808,7 +824,7 @@ impl<T: BitFlag> IntoIterator for BitFlags<T> {
808824
}
809825
}
810826

811-
/// Iterator that yields each set flag.
827+
/// Iterator that yields each flag set in a `BitFlags`.
812828
#[derive(Clone, Debug)]
813829
pub struct Iter<T: BitFlag> {
814830
rest: BitFlags<T>,

0 commit comments

Comments
 (0)