Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
iterator over all a types values
  • Loading branch information
shelvacu committed Sep 13, 2021
1 parent 2015484 commit 10aa329
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib.rs
Expand Up @@ -164,6 +164,13 @@ macro_rules! impl_ranged {
})
}

pub fn all_values() -> impl
core::iter::Iterator<Item=Self> +
core::iter::FusedIterator +
core::iter::DoubleEndedIterator {
(MIN..=MAX).into_iter().map(|n| unsafe { Self::new_unchecked(n) })
}

/// Returns the value as a primitive type.
pub const fn get(self) -> $internal {
unsafe_is_range!(MIN, MAX, self.0)
Expand Down

0 comments on commit 10aa329

Please sign in to comment.