[][src]Function randge::randge_barrel

pub fn randge_barrel<T: PrimInt + AsPrimitive<usize>>(
    range: Range<T>,
    n: T,
    rand: impl FnRand<T>
) -> RandgeIter<T, impl FnRand<T>, RangesBarrel<T>>

Notable traits for RandgeIter<T, F, R>

impl<T, F: FnRand<T>, R: RandgeTake<T>> Iterator for RandgeIter<T, F, R> where
    T: PrimInt
type Item = T;
where
    T: AsPrimitive<usize>,
    Range<T>: Iterator<Item = T>, 

Generate random numbers that are not repeated in the range

  • Space for time, time complexity is O(1)
  • Maximum memory usage
  • Fastest

Example

use rand::thread_rng;
 
let v = randge_barrel(-15..15, 5, thread_rng());
let v: Vec<_> = v.collect();
// output: like [13, -3, -14, 5, 3]