Skip to content

Commit 8fff98e

Browse files
matkladnagisa
authored andcommitted
choose_iter: use a better example
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
1 parent 74122c8 commit 8fff98e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/unstructured.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,14 @@ impl<'a> Unstructured<'a> {
420420
///
421421
/// # Examples
422422
///
423-
/// Selecting a random item from a hash set:
423+
/// Selecting a random item from a set:
424424
///
425425
/// ```
426-
/// use std::collections::HashSet;
426+
/// use std::collections::BTreeSet;
427427
/// use arbitrary::Unstructured;
428428
///
429429
/// let mut u = Unstructured::new(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
430-
/// let set = HashSet::from(['a', 'b', 'c']);
430+
/// let set = BTreeSet::from(['a', 'b', 'c']);
431431
///
432432
/// let choice = u.choose_iter(set.iter()).unwrap();
433433
///

0 commit comments

Comments
 (0)