new() should be const; start()/end() after iteration is unspecified.
This commit is contained in:
parent
c916ee8511
commit
f70b2ebd08
1 changed files with 17 additions and 1 deletions
|
@ -362,12 +362,20 @@ impl<Idx> RangeInclusive<Idx> {
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "inclusive_range_methods", issue = "49022")]
|
#[unstable(feature = "inclusive_range_methods", issue = "49022")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(start: Idx, end: Idx) -> Self {
|
pub const fn new(start: Idx, end: Idx) -> Self {
|
||||||
Self { start, end }
|
Self { start, end }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the lower bound of the range (inclusive).
|
/// 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
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -383,6 +391,14 @@ impl<Idx> RangeInclusive<Idx> {
|
||||||
|
|
||||||
/// Returns the upper bound of the range (inclusive).
|
/// 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
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue