Skip to content

Commit

Permalink
Add Clone to returned iterators where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
rossmacarthur committed Apr 21, 2024
1 parent 3da4a12 commit de2a585
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl Emoji {
/// assert!(cool.skin_tones().is_none());
/// ```
#[inline]
pub fn skin_tones(&self) -> Option<impl Iterator<Item = &Self>> {
pub fn skin_tones(&self) -> Option<impl Iterator<Item = &Self> + Clone> {
let (i, n, _) = self.skin_tone?;
Some(crate::gen::EMOJIS[i as usize..].iter().take(n as usize))
}
Expand Down Expand Up @@ -403,7 +403,7 @@ impl Emoji {
///
/// [gemoji]: https://github.com/github/gemoji
#[inline]
pub fn shortcodes(&self) -> impl Iterator<Item = &str> {
pub fn shortcodes(&self) -> impl Iterator<Item = &str> + Clone {
self.aliases.into_iter().flatten().copied()
}
}
Expand Down Expand Up @@ -470,7 +470,7 @@ impl Group {
/// assert_eq!(iter.next().unwrap(), emojis::Group::PeopleAndBody);
/// ```
#[inline]
pub fn iter() -> impl Iterator<Item = Group> {
pub fn iter() -> impl Iterator<Item = Group> + Clone {
[
Self::SmileysAndEmotion,
Self::PeopleAndBody,
Expand Down Expand Up @@ -515,7 +515,7 @@ impl Group {
/// assert_eq!(faces, ["😀", "😃", "😄", "😁", "😆"]);
/// ```
#[inline]
pub fn iter() -> impl Iterator<Item = &'static Emoji> {
pub fn iter() -> impl Iterator<Item = &'static Emoji> + Clone {
crate::gen::EMOJIS
.iter()
.filter(|emoji| matches!(emoji.skin_tone(), Some(SkinTone::Default) | None))
Expand Down

0 comments on commit de2a585

Please sign in to comment.