From ba769d833f3e3f71c9b0d7d39cd6aec268e2ad56 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 27 Jun 2014 12:29:41 -0400 Subject: [PATCH] Clarify range's exclusivity. Inspired by http://www.reddit.com/r/rust/comments/298js2/what_is_the_rationale_behind_the_second_parameter/ --- src/libcore/iter.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 855bccb07a741..6ba0f7c3a1575 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1962,7 +1962,19 @@ pub struct Range { 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 + PartialOrd + Clone + One>(start: A, stop: A) -> Range { Range{state: start, stop: stop, one: One::one()}