From eef43634035830f5572a6cb204c1b4e9ad46c468 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 8 Apr 2026 14:01:34 -0400 Subject: [PATCH] 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. --- library/core/src/range.rs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/library/core/src/range.rs b/library/core/src/range.rs index bdfb59b31834..1200f8922c81 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -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) -> 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) -> 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) -> 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) -> 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)]