Skip to content

Commit

Permalink
rand: Small fix in parameter name
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
Sawyer47 committed Jun 29, 2014
1 parent 6a3695d commit ba46c8b
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

5 comments on commit ba46c8b

@bors
Copy link
Contributor

@bors bors commented on ba46c8b Jun 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Sawyer47@ba46c8b

@bors
Copy link
Contributor

@bors bors commented on ba46c8b Jun 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Sawyer47/rust/rand-doc-fix = ba46c8b into auto

@bors
Copy link
Contributor

@bors bors commented on ba46c8b Jun 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sawyer47/rust/rand-doc-fix = ba46c8b merged ok, testing candidate = cc5663a

@bors
Copy link
Contributor

@bors bors commented on ba46c8b Jun 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = cc5663a

Please sign in to comment.