Skip to content

Commit efa9224

Browse files
Rollup merge of rust-lang#155002 - shepmaster:clarify-new-range, r=tgross35
Clarify that `core::range` ranges do not have special syntax r? @tgross35
2 parents 83e8133 + eef4363 commit efa9224

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

library/core/src/range.rs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ use crate::iter::Step;
4747
use crate::ops::Bound::{self, Excluded, Included, Unbounded};
4848
use crate::ops::{IntoBounds, OneSidedRange, OneSidedRangeBound, RangeBounds};
4949

50-
/// A (half-open) range bounded inclusively below and exclusively above
51-
/// (`start..end` in a future edition).
50+
/// A (half-open) range bounded inclusively below and exclusively above.
5251
///
53-
/// The range `start..end` contains all values with `start <= x < end`.
52+
/// The `Range` contains all values with `start <= x < end`.
5453
/// It is empty if `start >= end`.
5554
///
5655
/// # Examples
@@ -61,6 +60,11 @@ use crate::ops::{IntoBounds, OneSidedRange, OneSidedRangeBound, RangeBounds};
6160
/// assert_eq!(Range::from(3..5), Range { start: 3, end: 5 });
6261
/// assert_eq!(3 + 4 + 5, Range::from(3..6).into_iter().sum());
6362
/// ```
63+
///
64+
/// # Edition notes
65+
///
66+
/// It is planned that the syntax `start..end` will construct this
67+
/// type in a future edition, but it does not do so today.
6468
#[lang = "RangeCopy"]
6569
#[derive(Copy, Hash)]
6670
#[derive_const(Clone, Default, PartialEq, Eq)]
@@ -223,21 +227,24 @@ impl<T> const From<legacy::Range<T>> for Range<T> {
223227
}
224228
}
225229

226-
/// A range bounded inclusively below and above (`start..=last`).
230+
/// A range bounded inclusively below and above.
227231
///
228-
/// The `RangeInclusive` `start..=last` contains all values with `x >= start`
232+
/// The `RangeInclusive` contains all values with `x >= start`
229233
/// and `x <= last`. It is empty unless `start <= last`.
230234
///
231235
/// # Examples
232236
///
233-
/// The `start..=last` syntax is a `RangeInclusive`:
234-
///
235237
/// ```
236238
/// use core::range::RangeInclusive;
237239
///
238240
/// assert_eq!(RangeInclusive::from(3..=5), RangeInclusive { start: 3, last: 5 });
239241
/// assert_eq!(3 + 4 + 5, RangeInclusive::from(3..=5).into_iter().sum());
240242
/// ```
243+
///
244+
/// # Edition notes
245+
///
246+
/// It is planned that the syntax `start..=last` will construct this
247+
/// type in a future edition, but it does not do so today.
241248
#[lang = "RangeInclusiveCopy"]
242249
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
243250
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
@@ -407,9 +414,9 @@ impl<T> const From<legacy::RangeInclusive<T>> for RangeInclusive<T> {
407414
}
408415
}
409416

410-
/// A range only bounded inclusively below (`start..`).
417+
/// A range only bounded inclusively below.
411418
///
412-
/// The `RangeFrom` `start..` contains all values with `x >= start`.
419+
/// The `RangeFrom` contains all values with `x >= start`.
413420
///
414421
/// *Note*: Overflow in the [`IntoIterator`] implementation (when the contained
415422
/// data type reaches its numerical limit) is allowed to panic, wrap, or
@@ -423,14 +430,17 @@ impl<T> const From<legacy::RangeInclusive<T>> for RangeInclusive<T> {
423430
///
424431
/// # Examples
425432
///
426-
/// The `start..` syntax is a `RangeFrom`:
427-
///
428433
/// ```
429434
/// use core::range::RangeFrom;
430435
///
431436
/// assert_eq!(RangeFrom::from(2..), core::range::RangeFrom { start: 2 });
432437
/// assert_eq!(2 + 3 + 4, RangeFrom::from(2..).into_iter().take(3).sum());
433438
/// ```
439+
///
440+
/// # Edition notes
441+
///
442+
/// It is planned that the syntax `start..` will construct this
443+
/// type in a future edition, but it does not do so today.
434444
#[lang = "RangeFromCopy"]
435445
#[derive(Copy, Hash)]
436446
#[derive_const(Clone, PartialEq, Eq)]
@@ -564,15 +574,13 @@ impl<T> const From<legacy::RangeFrom<T>> for RangeFrom<T> {
564574
}
565575
}
566576

567-
/// A range only bounded inclusively above (`..=last`).
577+
/// A range only bounded inclusively above.
568578
///
569-
/// The `RangeToInclusive` `..=last` contains all values with `x <= last`.
579+
/// The `RangeToInclusive` contains all values with `x <= last`.
570580
/// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
571581
///
572582
/// # Examples
573583
///
574-
/// The `..=last` syntax is a `RangeToInclusive`:
575-
///
576584
/// ```standalone_crate
577585
/// #![feature(new_range)]
578586
/// assert_eq!((..=5), std::range::RangeToInclusive { last: 5 });
@@ -603,6 +611,11 @@ impl<T> const From<legacy::RangeFrom<T>> for RangeFrom<T> {
603611
/// ```
604612
///
605613
/// [slicing index]: crate::slice::SliceIndex
614+
///
615+
/// # Edition notes
616+
///
617+
/// It is planned that the syntax `..=last` will construct this
618+
/// type in a future edition, but it does not do so today.
606619
#[lang = "RangeToInclusiveCopy"]
607620
#[doc(alias = "..=")]
608621
#[derive(Copy, Clone, PartialEq, Eq, Hash)]

0 commit comments

Comments
 (0)