1
Fork 0

new() should be const; start()/end() after iteration is unspecified.

This commit is contained in:
kennytm 2018-04-07 14:19:34 +08:00
parent c916ee8511
commit f70b2ebd08
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C

View file

@ -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
///
/// ```
@ -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
///
/// ```