Skip to content

Commit

Permalink
Add function to iterate over groups
Browse files Browse the repository at this point in the history
  • Loading branch information
rossmacarthur committed Oct 17, 2022
1 parent 81507d2 commit 5bab0ac
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,31 @@ impl fmt::Display for Emoji {
}

impl Group {
/// Returns an iterator over all groups.
///
/// # Examples
///
/// ```
/// let mut iter = emojis::Group::iter();
/// assert_eq!(iter.next().unwrap(), emojis::Group::SmileysAndEmotion);
/// assert_eq!(iter.next().unwrap(), emojis::Group::PeopleAndBody);
/// ```
pub fn iter() -> impl Iterator<Item = Group> {
[
Self::SmileysAndEmotion,
Self::PeopleAndBody,
Self::AnimalsAndNature,
Self::FoodAndDrink,
Self::TravelAndPlaces,
Self::Activities,
Self::Objects,
Self::Symbols,
Self::Flags,
]
.iter()
.copied()
}

/// Returns an iterator over all emojis in this group.
///
/// # Examples
Expand Down

0 comments on commit 5bab0ac

Please sign in to comment.