diff options
| author | bors <bors@rust-lang.org> | 2014-07-22 00:26:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-22 00:26:21 +0000 |
| commit | aa0e35bc64b2b1f4b21bc653e74ba986e98610e2 (patch) | |
| tree | 3e808c2fa1800d9bc4d83e4faff6a5d43fb30b2a | |
| parent | 428d814a7d100f07feb87e4ffb7f4a0999bd556a (diff) | |
| parent | ba769d833f3e3f71c9b0d7d39cd6aec268e2ad56 (diff) | |
| download | rust-aa0e35bc64b2b1f4b21bc653e74ba986e98610e2.tar.gz rust-aa0e35bc64b2b1f4b21bc653e74ba986e98610e2.zip | |
auto merge of #15217 : steveklabnik/rust/range, r=huonw
Inspired by http://www.reddit.com/r/rust/comments/298js2/what_is_the_rationale_behind_the_second_parameter/
| -rw-r--r-- | src/libcore/iter.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 855bccb07a7..6ba0f7c3a15 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1962,7 +1962,19 @@ pub struct Range<A> { one: A } -/// Return an iterator over the range [start, stop) +/// Returns an iterator over the given range [start, stop) (that is, starting +/// at start (inclusive), and ending at stop (exclusive)). +/// +/// # Example +/// +/// ```rust +/// let array = [0, 1, 2, 3, 4]; +/// +/// for i in range(0, 5u) { +/// println!("{}", i); +/// assert_eq!(i, array[i]); +/// } +/// ``` #[inline] pub fn range<A: Add<A, A> + PartialOrd + Clone + One>(start: A, stop: A) -> Range<A> { Range{state: start, stop: stop, one: One::one()} |
