Skip to content

Commit

Permalink
new() should be const; start()/end() after iteration is unspecified.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Apr 30, 2018
1 parent c916ee8 commit f70b2eb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,20 @@ impl<Idx> RangeInclusive<Idx> {
/// ```
#[unstable(feature = "inclusive_range_methods", issue = "49022")]
#[inline]
pub fn new(start: Idx, end: Idx) -> Self {
pub const fn new(start: Idx, end: Idx) -> Self {
Self { start, end }
}

/// Returns the lower bound of the range (inclusive).
///
/// When using an inclusive range for iteration, the values of `start()` and
/// [`end()`] are unspecified after the iteration ended. To determine
/// whether the inclusive range is empty, use the [`is_empty()`] method
/// instead of comparing `start() > end()`.
///
/// [`end()`]: #method.end
/// [`is_empty()`]: #method.is_empty
///
/// # Examples
///
/// ```
Expand All @@ -383,6 +391,14 @@ impl<Idx> RangeInclusive<Idx> {

/// Returns the upper bound of the range (inclusive).
///
/// When using an inclusive range for iteration, the values of [`start()`]
/// and `end()` are unspecified after the iteration ended. To determine
/// whether the inclusive range is empty, use the [`is_empty()`] method
/// instead of comparing `start() > end()`.
///
/// [`start()`]: #method.start
/// [`is_empty()`]: #method.is_empty
///
/// # Examples
///
/// ```
Expand Down

0 comments on commit f70b2eb

Please sign in to comment.