Clarify that core::range::RangeInclusive does 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:00:50 -04:00
parent c771f6ee80
commit 092f0ca1bd
+7 -4
View File
@@ -223,21 +223,24 @@ fn from(value: legacy::Range<T>) -> Self {
}
}
/// A range bounded inclusively below and above (`start..=last`).
/// A range bounded inclusively below and above.
///
/// The `RangeInclusive` `start..=last` contains all values with `x >= start`
/// The `RangeInclusive` contains all values with `x >= start`
/// and `x <= last`. It is empty unless `start <= last`.
///
/// # Examples
///
/// The `start..=last` syntax is a `RangeInclusive`:
///
/// ```
/// use core::range::RangeInclusive;
///
/// assert_eq!(RangeInclusive::from(3..=5), RangeInclusive { start: 3, last: 5 });
/// assert_eq!(3 + 4 + 5, RangeInclusive::from(3..=5).into_iter().sum());
/// ```
///
/// # Edition notes
///
/// It is planned that the syntax `start..=last` will construct this
/// type in a future edition, but it does not do so today.
#[lang = "RangeInclusiveCopy"]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]