Skip to content

Commit 266ca31

Browse files
committed
Stabilize Range*::contains.
1 parent 8f4c226 commit 266ca31

File tree

5 files changed

+20
-34
lines changed

5 files changed

+20
-34
lines changed

src/libcore/ops/range.rs

+19-30
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl fmt::Debug for RangeFull {
6767
/// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
6868
/// ```
6969
#[doc(alias = "..")]
70-
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
70+
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
7171
#[stable(feature = "rust1", since = "1.0.0")]
7272
pub struct Range<Idx> {
7373
/// The lower bound of the range (inclusive).
@@ -91,8 +91,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
9191
/// # Examples
9292
///
9393
/// ```
94-
/// #![feature(range_contains)]
95-
///
9694
/// use std::f32;
9795
///
9896
/// assert!(!(3..5).contains(&2));
@@ -108,7 +106,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
108106
/// assert!(!(0.0..f32::NAN).contains(&0.5));
109107
/// assert!(!(f32::NAN..1.0).contains(&0.5));
110108
/// ```
111-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
109+
#[stable(feature = "range_contains", since = "1.35.0")]
112110
pub fn contains<U>(&self, item: &U) -> bool
113111
where
114112
Idx: PartialOrd<U>,
@@ -169,7 +167,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
169167
///
170168
/// [`Iterator`]: ../iter/trait.IntoIterator.html
171169
#[doc(alias = "..")]
172-
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
170+
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
173171
#[stable(feature = "rust1", since = "1.0.0")]
174172
pub struct RangeFrom<Idx> {
175173
/// The lower bound of the range (inclusive).
@@ -190,8 +188,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
190188
/// # Examples
191189
///
192190
/// ```
193-
/// #![feature(range_contains)]
194-
///
195191
/// use std::f32;
196192
///
197193
/// assert!(!(3..).contains(&2));
@@ -202,7 +198,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
202198
/// assert!(!(0.0..).contains(&f32::NAN));
203199
/// assert!(!(f32::NAN..).contains(&0.5));
204200
/// ```
205-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
201+
#[stable(feature = "range_contains", since = "1.35.0")]
206202
pub fn contains<U>(&self, item: &U) -> bool
207203
where
208204
Idx: PartialOrd<U>,
@@ -272,8 +268,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
272268
/// # Examples
273269
///
274270
/// ```
275-
/// #![feature(range_contains)]
276-
///
277271
/// use std::f32;
278272
///
279273
/// assert!( (..5).contains(&-1_000_000_000));
@@ -284,7 +278,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
284278
/// assert!(!(..1.0).contains(&f32::NAN));
285279
/// assert!(!(..f32::NAN).contains(&0.5));
286280
/// ```
287-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
281+
#[stable(feature = "range_contains", since = "1.35.0")]
288282
pub fn contains<U>(&self, item: &U) -> bool
289283
where
290284
Idx: PartialOrd<U>,
@@ -317,7 +311,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
317311
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
318312
/// ```
319313
#[doc(alias = "..=")]
320-
#[derive(Clone)] // not Copy -- see #27186
314+
#[derive(Clone)] // not Copy -- see #27186
321315
#[stable(feature = "inclusive_range", since = "1.26.0")]
322316
pub struct RangeInclusive<Idx> {
323317
pub(crate) start: Idx,
@@ -353,7 +347,8 @@ impl<T: PartialOrd> RangeInclusiveEquality for T {
353347
impl<Idx: PartialEq> PartialEq for RangeInclusive<Idx> {
354348
#[inline]
355349
fn eq(&self, other: &Self) -> bool {
356-
self.start == other.start && self.end == other.end
350+
self.start == other.start
351+
&& self.end == other.end
357352
&& RangeInclusiveEquality::canonicalized_is_empty(self)
358353
== RangeInclusiveEquality::canonicalized_is_empty(other)
359354
}
@@ -385,7 +380,11 @@ impl<Idx> RangeInclusive<Idx> {
385380
#[inline]
386381
#[rustc_promotable]
387382
pub const fn new(start: Idx, end: Idx) -> Self {
388-
Self { start, end, is_empty: None }
383+
Self {
384+
start,
385+
end,
386+
is_empty: None,
387+
}
389388
}
390389

391390
/// Returns the lower bound of the range (inclusive).
@@ -466,8 +465,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
466465
/// # Examples
467466
///
468467
/// ```
469-
/// #![feature(range_contains)]
470-
///
471468
/// use std::f32;
472469
///
473470
/// assert!(!(3..=5).contains(&2));
@@ -484,7 +481,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
484481
/// assert!(!(0.0..=f32::NAN).contains(&0.0));
485482
/// assert!(!(f32::NAN..=1.0).contains(&1.0));
486483
/// ```
487-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
484+
#[stable(feature = "range_contains", since = "1.35.0")]
488485
pub fn contains<U>(&self, item: &U) -> bool
489486
where
490487
Idx: PartialOrd<U>,
@@ -593,15 +590,12 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
593590
}
594591
}
595592

596-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
597593
impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
598594
/// Returns `true` if `item` is contained in the range.
599595
///
600596
/// # Examples
601597
///
602598
/// ```
603-
/// #![feature(range_contains)]
604-
///
605599
/// use std::f32;
606600
///
607601
/// assert!( (..=5).contains(&-1_000_000_000));
@@ -612,7 +606,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
612606
/// assert!(!(..=1.0).contains(&f32::NAN));
613607
/// assert!(!(..=f32::NAN).contains(&0.5));
614608
/// ```
615-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
609+
#[stable(feature = "range_contains", since = "1.35.0")]
616610
pub fn contains<U>(&self, item: &U) -> bool
617611
where
618612
Idx: PartialOrd<U>,
@@ -714,14 +708,11 @@ pub trait RangeBounds<T: ?Sized> {
714708
#[stable(feature = "collections_range", since = "1.28.0")]
715709
fn end_bound(&self) -> Bound<&T>;
716710

717-
718711
/// Returns `true` if `item` is contained in the range.
719712
///
720713
/// # Examples
721714
///
722715
/// ```
723-
/// #![feature(range_contains)]
724-
///
725716
/// use std::f32;
726717
///
727718
/// assert!( (3..5).contains(&4));
@@ -731,7 +722,7 @@ pub trait RangeBounds<T: ?Sized> {
731722
/// assert!(!(0.0..1.0).contains(&f32::NAN));
732723
/// assert!(!(0.0..f32::NAN).contains(&0.5));
733724
/// assert!(!(f32::NAN..1.0).contains(&0.5));
734-
#[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
725+
#[stable(feature = "range_contains", since = "1.35.0")]
735726
fn contains<U>(&self, item: &U) -> bool
736727
where
737728
T: PartialOrd<U>,
@@ -741,9 +732,7 @@ pub trait RangeBounds<T: ?Sized> {
741732
Included(ref start) => *start <= item,
742733
Excluded(ref start) => *start < item,
743734
Unbounded => true,
744-
})
745-
&&
746-
(match self.end_bound() {
735+
}) && (match self.end_bound() {
747736
Included(ref end) => item <= *end,
748737
Excluded(ref end) => item < *end,
749738
Unbounded => true,
@@ -819,15 +808,15 @@ impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
819808
match *self {
820809
(Included(ref start), _) => Included(start),
821810
(Excluded(ref start), _) => Excluded(start),
822-
(Unbounded, _) => Unbounded,
811+
(Unbounded, _) => Unbounded,
823812
}
824813
}
825814

826815
fn end_bound(&self) -> Bound<&T> {
827816
match *self {
828817
(_, Included(ref end)) => Included(end),
829818
(_, Excluded(ref end)) => Excluded(end),
830-
(_, Unbounded) => Unbounded,
819+
(_, Unbounded) => Unbounded,
831820
}
832821
}
833822
}

src/librustc_codegen_llvm/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![allow(unused_attributes)]
1616
#![feature(libc)]
1717
#![feature(nll)]
18-
#![feature(range_contains)]
1918
#![feature(rustc_diagnostic_macros)]
2019
#![feature(optin_builtin_traits)]
2120
#![feature(concat_idents)]

src/librustc_errors/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#![feature(custom_attribute)]
44
#![allow(unused_attributes)]
5-
#![feature(range_contains)]
65
#![cfg_attr(unix, feature(libc))]
76
#![feature(nll)]
87
#![feature(optin_builtin_traits)]

src/librustc_mir/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
1414
#![feature(const_fn)]
1515
#![feature(decl_macro)]
1616
#![feature(exhaustive_patterns)]
17-
#![feature(range_contains)]
1817
#![feature(rustc_diagnostic_macros)]
1918
#![feature(rustc_attrs)]
2019
#![feature(never_type)]

src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221

222222
#![cfg_attr(test, feature(print_internals, set_stdio, test, update_panic_count))]
223223
#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"),
224-
feature(global_asm, range_contains, slice_index_methods,
224+
feature(global_asm, slice_index_methods,
225225
decl_macro, coerce_unsized, sgx_platform, ptr_wrapping_offset_from))]
226226

227227
// std is implemented with unstable features, many of which are internal

0 commit comments

Comments
 (0)