@@ -71,7 +71,7 @@ impl fmt::Debug for RangeFull {
71
71
/// assert_eq!(arr[1..=3], [ 1,2,3 ]);
72
72
/// ```
73
73
#[ doc( alias = ".." ) ]
74
- #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
74
+ #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
75
75
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
76
76
pub struct Range < Idx > {
77
77
/// The lower bound of the range (inclusive).
@@ -95,8 +95,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
95
95
/// # Examples
96
96
///
97
97
/// ```
98
- /// #![feature(range_contains)]
99
- ///
100
98
/// use std::f32;
101
99
///
102
100
/// assert!(!(3..5).contains(&2));
@@ -112,7 +110,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
112
110
/// assert!(!(0.0..f32::NAN).contains(&0.5));
113
111
/// assert!(!(f32::NAN..1.0).contains(&0.5));
114
112
/// ```
115
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
113
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
116
114
pub fn contains < U > ( & self , item : & U ) -> bool
117
115
where
118
116
Idx : PartialOrd < U > ,
@@ -175,7 +173,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
175
173
///
176
174
/// [`Iterator`]: ../iter/trait.IntoIterator.html
177
175
#[ doc( alias = ".." ) ]
178
- #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
176
+ #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
179
177
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
180
178
pub struct RangeFrom < Idx > {
181
179
/// The lower bound of the range (inclusive).
@@ -196,8 +194,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
196
194
/// # Examples
197
195
///
198
196
/// ```
199
- /// #![feature(range_contains)]
200
- ///
201
197
/// use std::f32;
202
198
///
203
199
/// assert!(!(3..).contains(&2));
@@ -208,7 +204,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
208
204
/// assert!(!(0.0..).contains(&f32::NAN));
209
205
/// assert!(!(f32::NAN..).contains(&0.5));
210
206
/// ```
211
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
207
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
212
208
pub fn contains < U > ( & self , item : & U ) -> bool
213
209
where
214
210
Idx : PartialOrd < U > ,
@@ -280,8 +276,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
280
276
/// # Examples
281
277
///
282
278
/// ```
283
- /// #![feature(range_contains)]
284
- ///
285
279
/// use std::f32;
286
280
///
287
281
/// assert!( (..5).contains(&-1_000_000_000));
@@ -292,7 +286,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
292
286
/// assert!(!(..1.0).contains(&f32::NAN));
293
287
/// assert!(!(..f32::NAN).contains(&0.5));
294
288
/// ```
295
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
289
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
296
290
pub fn contains < U > ( & self , item : & U ) -> bool
297
291
where
298
292
Idx : PartialOrd < U > ,
@@ -329,7 +323,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
329
323
/// assert_eq!(arr[1..=3], [ 1,2,3 ]); // RangeInclusive
330
324
/// ```
331
325
#[ doc( alias = "..=" ) ]
332
- #[ derive( Clone ) ] // not Copy -- see #27186
326
+ #[ derive( Clone ) ] // not Copy -- see #27186
333
327
#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
334
328
pub struct RangeInclusive < Idx > {
335
329
pub ( crate ) start : Idx ,
@@ -365,7 +359,8 @@ impl<T: PartialOrd> RangeInclusiveEquality for T {
365
359
impl < Idx : PartialEq > PartialEq for RangeInclusive < Idx > {
366
360
#[ inline]
367
361
fn eq ( & self , other : & Self ) -> bool {
368
- self . start == other. start && self . end == other. end
362
+ self . start == other. start
363
+ && self . end == other. end
369
364
&& RangeInclusiveEquality :: canonicalized_is_empty ( self )
370
365
== RangeInclusiveEquality :: canonicalized_is_empty ( other)
371
366
}
@@ -397,7 +392,11 @@ impl<Idx> RangeInclusive<Idx> {
397
392
#[ inline]
398
393
#[ rustc_promotable]
399
394
pub const fn new ( start : Idx , end : Idx ) -> Self {
400
- Self { start, end, is_empty : None }
395
+ Self {
396
+ start,
397
+ end,
398
+ is_empty : None ,
399
+ }
401
400
}
402
401
403
402
/// Returns the lower bound of the range (inclusive).
@@ -478,8 +477,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
478
477
/// # Examples
479
478
///
480
479
/// ```
481
- /// #![feature(range_contains)]
482
- ///
483
480
/// use std::f32;
484
481
///
485
482
/// assert!(!(3..=5).contains(&2));
@@ -496,7 +493,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
496
493
/// assert!(!(0.0..=f32::NAN).contains(&0.0));
497
494
/// assert!(!(f32::NAN..=1.0).contains(&1.0));
498
495
/// ```
499
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
496
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
500
497
pub fn contains < U > ( & self , item : & U ) -> bool
501
498
where
502
499
Idx : PartialOrd < U > ,
@@ -609,15 +606,12 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
609
606
}
610
607
}
611
608
612
- #[ unstable( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311" ) ]
613
609
impl < Idx : PartialOrd < Idx > > RangeToInclusive < Idx > {
614
610
/// Returns `true` if `item` is contained in the range.
615
611
///
616
612
/// # Examples
617
613
///
618
614
/// ```
619
- /// #![feature(range_contains)]
620
- ///
621
615
/// use std::f32;
622
616
///
623
617
/// assert!( (..=5).contains(&-1_000_000_000));
@@ -628,7 +622,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
628
622
/// assert!(!(..=1.0).contains(&f32::NAN));
629
623
/// assert!(!(..=f32::NAN).contains(&0.5));
630
624
/// ```
631
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
625
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
632
626
pub fn contains < U > ( & self , item : & U ) -> bool
633
627
where
634
628
Idx : PartialOrd < U > ,
@@ -730,14 +724,11 @@ pub trait RangeBounds<T: ?Sized> {
730
724
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
731
725
fn end_bound ( & self ) -> Bound < & T > ;
732
726
733
-
734
727
/// Returns `true` if `item` is contained in the range.
735
728
///
736
729
/// # Examples
737
730
///
738
731
/// ```
739
- /// #![feature(range_contains)]
740
- ///
741
732
/// use std::f32;
742
733
///
743
734
/// assert!( (3..5).contains(&4));
@@ -747,7 +738,7 @@ pub trait RangeBounds<T: ?Sized> {
747
738
/// assert!(!(0.0..1.0).contains(&f32::NAN));
748
739
/// assert!(!(0.0..f32::NAN).contains(&0.5));
749
740
/// assert!(!(f32::NAN..1.0).contains(&0.5));
750
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
741
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
751
742
fn contains < U > ( & self , item : & U ) -> bool
752
743
where
753
744
T : PartialOrd < U > ,
@@ -757,9 +748,7 @@ pub trait RangeBounds<T: ?Sized> {
757
748
Included ( ref start) => * start <= item,
758
749
Excluded ( ref start) => * start < item,
759
750
Unbounded => true ,
760
- } )
761
- &&
762
- ( match self . end_bound ( ) {
751
+ } ) && ( match self . end_bound ( ) {
763
752
Included ( ref end) => item <= * end,
764
753
Excluded ( ref end) => item < * end,
765
754
Unbounded => true ,
@@ -835,15 +824,15 @@ impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
835
824
match * self {
836
825
( Included ( ref start) , _) => Included ( start) ,
837
826
( Excluded ( ref start) , _) => Excluded ( start) ,
838
- ( Unbounded , _) => Unbounded ,
827
+ ( Unbounded , _) => Unbounded ,
839
828
}
840
829
}
841
830
842
831
fn end_bound ( & self ) -> Bound < & T > {
843
832
match * self {
844
833
( _, Included ( ref end) ) => Included ( end) ,
845
834
( _, Excluded ( ref end) ) => Excluded ( end) ,
846
- ( _, Unbounded ) => Unbounded ,
835
+ ( _, Unbounded ) => Unbounded ,
847
836
}
848
837
}
849
838
}
0 commit comments