Skip to content

Commit

Permalink
choose_iter: use a better example
Browse files Browse the repository at this point in the history
As I have just found out, passing a HashSet to choose_iter is not such a
bright idea, because hash set's order is non-deterministic. Use BTreeSet
in the example, and call this out in docs
  • Loading branch information
matklad authored and nagisa committed Jul 4, 2024
1 parent 74122c8 commit 8fff98e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/unstructured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,14 @@ impl<'a> Unstructured<'a> {
///
/// # Examples
///
/// Selecting a random item from a hash set:
/// Selecting a random item from a set:
///
/// ```
/// use std::collections::HashSet;
/// use std::collections::BTreeSet;
/// use arbitrary::Unstructured;
///
/// let mut u = Unstructured::new(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
/// let set = HashSet::from(['a', 'b', 'c']);
/// let set = BTreeSet::from(['a', 'b', 'c']);
///
/// let choice = u.choose_iter(set.iter()).unwrap();
///
Expand Down

0 comments on commit 8fff98e

Please sign in to comment.