@@ -273,6 +273,11 @@ impl<'a> Unstructured<'a> {
273
273
/// Do not use this to generate the size of a collection. Use
274
274
/// `arbitrary_len` instead.
275
275
///
276
+ /// The probability distribution of the return value is not necessarily uniform.
277
+ ///
278
+ /// Returns `range.start()`, not an error,
279
+ /// if this `Unstructured` [is empty][Unstructured::is_empty].
280
+ ///
276
281
/// # Panics
277
282
///
278
283
/// Panics if `range.start > range.end`. That is, the given range must be
@@ -377,8 +382,12 @@ impl<'a> Unstructured<'a> {
377
382
///
378
383
/// This should only be used inside of `Arbitrary` implementations.
379
384
///
380
- /// Returns an error if there is not enough underlying data to make a
381
- /// choice or if no choices are provided.
385
+ /// The probability distribution of choices is not necessarily uniform.
386
+ ///
387
+ /// Returns the first choice, not an error,
388
+ /// if this `Unstructured` [is empty][Unstructured::is_empty].
389
+ ///
390
+ /// Returns an error if no choices are provided.
382
391
///
383
392
/// # Examples
384
393
///
@@ -416,8 +425,12 @@ impl<'a> Unstructured<'a> {
416
425
///
417
426
/// This should only be used inside of `Arbitrary` implementations.
418
427
///
419
- /// Returns an error if there is not enough underlying data to make a
420
- /// choice or if no choices are provided.
428
+ /// The probability distribution of choices is not necessarily uniform.
429
+ ///
430
+ /// Returns the first choice, not an error,
431
+ /// if this `Unstructured` [is empty][Unstructured::is_empty].
432
+ ///
433
+ /// Returns an error if no choices are provided.
421
434
///
422
435
/// # Examples
423
436
///
@@ -449,6 +462,10 @@ impl<'a> Unstructured<'a> {
449
462
450
463
/// Choose a value in `0..len`.
451
464
///
465
+ /// The probability distribution of return values is not necessarily uniform.
466
+ ///
467
+ /// Returns zero, not an error, if this `Unstructured` [is empty][Unstructured::is_empty].
468
+ ///
452
469
/// Returns an error if the `len` is zero.
453
470
///
454
471
/// # Examples
@@ -492,7 +509,9 @@ impl<'a> Unstructured<'a> {
492
509
Ok ( idx)
493
510
}
494
511
495
- /// Generate a boolean according to the given ratio.
512
+ /// Generate a boolean which is true with probability approximately the given ratio.
513
+ ///
514
+ /// Returns true, not an error, if this `Unstructured` [is empty][Unstructured::is_empty].
496
515
///
497
516
/// # Panics
498
517
///
@@ -512,7 +531,7 @@ impl<'a> Unstructured<'a> {
512
531
/// let mut u = Unstructured::new(&my_data);
513
532
///
514
533
/// if u.ratio(5, 7)? {
515
- /// // Take this branch 5/7 of the time.
534
+ /// // Take this branch approximately 5/7 of the time.
516
535
/// }
517
536
/// # Ok(())
518
537
/// # }
0 commit comments