Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions library/core/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl<Idx: Step> Range<Idx> {
/// assert_eq!(i.next(), Some(25));
/// ```
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn iter(&self) -> RangeIter<Idx> {
self.clone().into_iter()
}
Expand All @@ -131,7 +130,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// assert!(!Range::from(0.0..f32::NAN).contains(&0.5));
/// assert!(!Range::from(f32::NAN..1.0).contains(&0.5));
/// ```
#[inline]
Copy link
Copy Markdown
Contributor

@asder8215 asder8215 Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the Rust stdlibs dev guide tells you that you shouldn't need to #[inline] methods that have generics involved, but I do see that the previous Range types inline for methods like these.

Unsure if this would cause performance regression and if the rust compiler inlines this automatically without this attribute.

View changes since the review

#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub const fn contains<U>(&self, item: &U) -> bool
Expand Down Expand Up @@ -163,7 +161,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// assert!( Range::from(3.0..f32::NAN).is_empty());
/// assert!( Range::from(f32::NAN..5.0).is_empty());
/// ```
#[inline]
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub const fn is_empty(&self) -> bool
Expand Down Expand Up @@ -213,15 +210,13 @@ impl<T> const IntoBounds<T> for Range<T> {
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<T> const From<Range<T>> for legacy::Range<T> {
#[inline]
fn from(value: Range<T>) -> Self {
Self { start: value.start, end: value.end }
}
}
#[stable(feature = "new_range_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<T> const From<legacy::Range<T>> for Range<T> {
#[inline]
fn from(value: legacy::Range<T>) -> Self {
Self { start: value.start, end: value.end }
}
Expand Down Expand Up @@ -289,7 +284,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// assert!(!RangeInclusive::from(0.0..=f32::NAN).contains(&0.0));
/// assert!(!RangeInclusive::from(f32::NAN..=1.0).contains(&1.0));
/// ```
#[inline]
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub const fn contains<U>(&self, item: &U) -> bool
Expand Down Expand Up @@ -322,7 +316,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// assert!( RangeInclusive::from(f32::NAN..=5.0).is_empty());
/// ```
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
#[inline]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub const fn is_empty(&self) -> bool
where
Expand All @@ -348,7 +341,6 @@ impl<Idx: Step> RangeInclusive<Idx> {
/// assert_eq!(i.next(), Some(25));
/// ```
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
#[inline]
pub fn iter(&self) -> RangeInclusiveIter<Idx> {
self.clone().into_iter()
}
Expand Down Expand Up @@ -394,15 +386,13 @@ impl<T> const IntoBounds<T> for RangeInclusive<T> {
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<T> const From<RangeInclusive<T>> for legacy::RangeInclusive<T> {
#[inline]
fn from(value: RangeInclusive<T>) -> Self {
Self::new(value.start, value.last)
}
}
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl<T> const From<legacy::RangeInclusive<T>> for RangeInclusive<T> {
#[inline]
fn from(value: legacy::RangeInclusive<T>) -> Self {
assert!(
!value.exhausted,
Expand Down Expand Up @@ -476,7 +466,6 @@ impl<Idx: Step> RangeFrom<Idx> {
/// assert_eq!(i.next(), Some(25));
/// ```
#[stable(feature = "new_range_from_api", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn iter(&self) -> RangeFromIter<Idx> {
self.clone().into_iter()
}
Expand All @@ -498,7 +487,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
/// assert!(!RangeFrom::from(0.0..).contains(&f32::NAN));
/// assert!(!RangeFrom::from(f32::NAN..).contains(&0.5));
/// ```
#[inline]
#[stable(feature = "new_range_from_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub const fn contains<U>(&self, item: &U) -> bool
Expand Down Expand Up @@ -560,15 +548,13 @@ where
#[stable(feature = "new_range_from_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
impl<T> const From<RangeFrom<T>> for legacy::RangeFrom<T> {
#[inline]
fn from(value: RangeFrom<T>) -> Self {
Self { start: value.start }
}
}
#[stable(feature = "new_range_from_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
impl<T> const From<legacy::RangeFrom<T>> for RangeFrom<T> {
#[inline]
fn from(value: legacy::RangeFrom<T>) -> Self {
Self { start: value.start }
}
Expand Down Expand Up @@ -649,7 +635,6 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
/// assert!(!(..=1.0).contains(&f32::NAN));
/// assert!(!(..=f32::NAN).contains(&0.5));
/// ```
#[inline]
#[stable(feature = "new_range_to_inclusive_api", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub const fn contains<U>(&self, item: &U) -> bool
Expand Down
Loading