Skip to content

Commit

Permalink
Rebase atop master
Browse files Browse the repository at this point in the history
  • Loading branch information
notgull committed Mar 2, 2023
1 parent e76c79c commit bd9394f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/global_rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ pub fn uppercase() -> char {
with_rng(|r| r.uppercase())
}

/// Choose an item from an iterator at random.
///
/// This function may have an unexpected result if the `len()` property of the
/// iterator does not match the actual number of items in the iterator. If
/// the iterator is empty, this returns `None`.
#[inline]
pub fn choice<I>(iter: I) -> Option<I::Item>
where
I: IntoIterator,
I::IntoIter: ExactSizeIterator,
{
with_rng(|r| r.choice(iter))
}

/// Generates a random digit in the given `base`.
///
/// Digits are represented by `char`s in ranges 0-9 and a-z.
Expand Down

0 comments on commit bd9394f

Please sign in to comment.