Clarify that core::range::{Range,RangeFrom,RangeToInclusive} do not have special syntax

I'm ignoring the fact that there's a feature to change the behavior of
the syntax. I just want to help prevent confusing the people reading
the docs.
This commit is contained in:
Jake Goulding
2026-04-08 14:01:34 -04:00
parent 092f0ca1bd
commit eef4363403
+21 -11
View File
@@ -47,10 +47,9 @@
use crate::ops::Bound::{self, Excluded, Included, Unbounded};
use crate::ops::{IntoBounds, OneSidedRange, OneSidedRangeBound, RangeBounds};
/// A (half-open) range bounded inclusively below and exclusively above
/// (`start..end` in a future edition).
/// A (half-open) range bounded inclusively below and exclusively above.
///
/// The range `start..end` contains all values with `start <= x < end`.
/// The `Range` contains all values with `start <= x < end`.
/// It is empty if `start >= end`.
///
/// # Examples
@@ -61,6 +60,11 @@
/// assert_eq!(Range::from(3..5), Range { start: 3, end: 5 });
/// assert_eq!(3 + 4 + 5, Range::from(3..6).into_iter().sum());
/// ```
///
/// # Edition notes
///
/// It is planned that the syntax `start..end` will construct this
/// type in a future edition, but it does not do so today.
#[lang = "RangeCopy"]
#[derive(Copy, Hash)]
#[derive_const(Clone, Default, PartialEq, Eq)]
@@ -410,9 +414,9 @@ fn from(value: legacy::RangeInclusive<T>) -> Self {
}
}
/// A range only bounded inclusively below (`start..`).
/// A range only bounded inclusively below.
///
/// The `RangeFrom` `start..` contains all values with `x >= start`.
/// The `RangeFrom` contains all values with `x >= start`.
///
/// *Note*: Overflow in the [`IntoIterator`] implementation (when the contained
/// data type reaches its numerical limit) is allowed to panic, wrap, or
@@ -426,14 +430,17 @@ fn from(value: legacy::RangeInclusive<T>) -> Self {
///
/// # Examples
///
/// The `start..` syntax is a `RangeFrom`:
///
/// ```
/// use core::range::RangeFrom;
///
/// assert_eq!(RangeFrom::from(2..), core::range::RangeFrom { start: 2 });
/// assert_eq!(2 + 3 + 4, RangeFrom::from(2..).into_iter().take(3).sum());
/// ```
///
/// # Edition notes
///
/// It is planned that the syntax `start..` will construct this
/// type in a future edition, but it does not do so today.
#[lang = "RangeFromCopy"]
#[derive(Copy, Hash)]
#[derive_const(Clone, PartialEq, Eq)]
@@ -567,15 +574,13 @@ fn from(value: legacy::RangeFrom<T>) -> Self {
}
}
/// A range only bounded inclusively above (`..=last`).
/// A range only bounded inclusively above.
///
/// The `RangeToInclusive` `..=last` contains all values with `x <= last`.
/// The `RangeToInclusive` contains all values with `x <= last`.
/// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
///
/// # Examples
///
/// The `..=last` syntax is a `RangeToInclusive`:
///
/// ```standalone_crate
/// #![feature(new_range)]
/// assert_eq!((..=5), std::range::RangeToInclusive { last: 5 });
@@ -606,6 +611,11 @@ fn from(value: legacy::RangeFrom<T>) -> Self {
/// ```
///
/// [slicing index]: crate::slice::SliceIndex
///
/// # Edition notes
///
/// It is planned that the syntax `..=last` will construct this
/// type in a future edition, but it does not do so today.
#[lang = "RangeToInclusiveCopy"]
#[doc(alias = "..=")]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]