Skip to content

Commit

Permalink
auto merge of #15246 : Sawyer47/rust/rand-doc-fix, r=alexcrichton
Browse files Browse the repository at this point in the history
Documentation didn't match with parameter name.
Changes name of parameter in docs and function to 'amount'.
  • Loading branch information
bors committed Jun 29, 2014
2 parents bd9563a + ba46c8b commit cc5663a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libstd/rand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub fn random<T: Rand>() -> T {
task_rng().gen()
}

/// Randomly sample up to `n` elements from an iterator.
/// Randomly sample up to `amount` elements from an iterator.
///
/// # Example
///
Expand All @@ -257,11 +257,11 @@ pub fn random<T: Rand>() -> T {
/// ```
pub fn sample<T, I: Iterator<T>, R: Rng>(rng: &mut R,
mut iter: I,
amt: uint) -> Vec<T> {
let mut reservoir: Vec<T> = iter.by_ref().take(amt).collect();
amount: uint) -> Vec<T> {
let mut reservoir: Vec<T> = 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;
}
}
Expand Down

0 comments on commit cc5663a

Please sign in to comment.