From ba46c8bf6686f3edf67d8aa7587956e7d5d7375a Mon Sep 17 00:00:00 2001 From: Piotr Jawniak Date: Sun, 29 Jun 2014 09:32:19 +0200 Subject: [PATCH] rand: Small fix in parameter name Documentation didn't match with parameter name. Changes name of parameter in docs and function to 'amount'. --- src/libstd/rand/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index ffe4a94d2a2..f48d487461e 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -244,7 +244,7 @@ pub fn random() -> T { task_rng().gen() } -/// Randomly sample up to `n` elements from an iterator. +/// Randomly sample up to `amount` elements from an iterator. /// /// # Example /// @@ -257,11 +257,11 @@ pub fn random() -> T { /// ``` pub fn sample, R: Rng>(rng: &mut R, mut iter: I, - amt: uint) -> Vec { - let mut reservoir: Vec = iter.by_ref().take(amt).collect(); + amount: uint) -> Vec { + let mut reservoir: Vec = iter.by_ref().take(amount).collect(); for (i, elem) in iter.enumerate() { - let k = rng.gen_range(0, i + 1 + amt); - if k < amt { + let k = rng.gen_range(0, i + 1 + amount); + if k < amount { *reservoir.get_mut(k) = elem; } }