@@ -67,7 +67,7 @@ impl fmt::Debug for RangeFull {
67
67
/// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
68
68
/// ```
69
69
#[ doc( alias = ".." ) ]
70
- #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
70
+ #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
71
71
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
72
72
pub struct Range < Idx > {
73
73
/// The lower bound of the range (inclusive).
@@ -91,8 +91,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
91
91
/// # Examples
92
92
///
93
93
/// ```
94
- /// #![feature(range_contains)]
95
- ///
96
94
/// use std::f32;
97
95
///
98
96
/// assert!(!(3..5).contains(&2));
@@ -108,7 +106,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
108
106
/// assert!(!(0.0..f32::NAN).contains(&0.5));
109
107
/// assert!(!(f32::NAN..1.0).contains(&0.5));
110
108
/// ```
111
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
109
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
112
110
pub fn contains < U > ( & self , item : & U ) -> bool
113
111
where
114
112
Idx : PartialOrd < U > ,
@@ -169,7 +167,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
169
167
///
170
168
/// [`Iterator`]: ../iter/trait.IntoIterator.html
171
169
#[ doc( alias = ".." ) ]
172
- #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
170
+ #[ derive( Clone , PartialEq , Eq , Hash ) ] // not Copy -- see #27186
173
171
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
174
172
pub struct RangeFrom < Idx > {
175
173
/// The lower bound of the range (inclusive).
@@ -190,8 +188,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
190
188
/// # Examples
191
189
///
192
190
/// ```
193
- /// #![feature(range_contains)]
194
- ///
195
191
/// use std::f32;
196
192
///
197
193
/// assert!(!(3..).contains(&2));
@@ -202,7 +198,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
202
198
/// assert!(!(0.0..).contains(&f32::NAN));
203
199
/// assert!(!(f32::NAN..).contains(&0.5));
204
200
/// ```
205
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
201
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
206
202
pub fn contains < U > ( & self , item : & U ) -> bool
207
203
where
208
204
Idx : PartialOrd < U > ,
@@ -272,8 +268,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
272
268
/// # Examples
273
269
///
274
270
/// ```
275
- /// #![feature(range_contains)]
276
- ///
277
271
/// use std::f32;
278
272
///
279
273
/// assert!( (..5).contains(&-1_000_000_000));
@@ -284,7 +278,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
284
278
/// assert!(!(..1.0).contains(&f32::NAN));
285
279
/// assert!(!(..f32::NAN).contains(&0.5));
286
280
/// ```
287
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
281
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
288
282
pub fn contains < U > ( & self , item : & U ) -> bool
289
283
where
290
284
Idx : PartialOrd < U > ,
@@ -317,7 +311,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
317
311
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
318
312
/// ```
319
313
#[ doc( alias = "..=" ) ]
320
- #[ derive( Clone ) ] // not Copy -- see #27186
314
+ #[ derive( Clone ) ] // not Copy -- see #27186
321
315
#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
322
316
pub struct RangeInclusive < Idx > {
323
317
pub ( crate ) start : Idx ,
@@ -353,7 +347,8 @@ impl<T: PartialOrd> RangeInclusiveEquality for T {
353
347
impl < Idx : PartialEq > PartialEq for RangeInclusive < Idx > {
354
348
#[ inline]
355
349
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
357
352
&& RangeInclusiveEquality :: canonicalized_is_empty ( self )
358
353
== RangeInclusiveEquality :: canonicalized_is_empty ( other)
359
354
}
@@ -385,7 +380,11 @@ impl<Idx> RangeInclusive<Idx> {
385
380
#[ inline]
386
381
#[ rustc_promotable]
387
382
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
+ }
389
388
}
390
389
391
390
/// Returns the lower bound of the range (inclusive).
@@ -466,8 +465,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
466
465
/// # Examples
467
466
///
468
467
/// ```
469
- /// #![feature(range_contains)]
470
- ///
471
468
/// use std::f32;
472
469
///
473
470
/// assert!(!(3..=5).contains(&2));
@@ -484,7 +481,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
484
481
/// assert!(!(0.0..=f32::NAN).contains(&0.0));
485
482
/// assert!(!(f32::NAN..=1.0).contains(&1.0));
486
483
/// ```
487
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
484
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
488
485
pub fn contains < U > ( & self , item : & U ) -> bool
489
486
where
490
487
Idx : PartialOrd < U > ,
@@ -593,15 +590,12 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
593
590
}
594
591
}
595
592
596
- #[ unstable( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311" ) ]
597
593
impl < Idx : PartialOrd < Idx > > RangeToInclusive < Idx > {
598
594
/// Returns `true` if `item` is contained in the range.
599
595
///
600
596
/// # Examples
601
597
///
602
598
/// ```
603
- /// #![feature(range_contains)]
604
- ///
605
599
/// use std::f32;
606
600
///
607
601
/// assert!( (..=5).contains(&-1_000_000_000));
@@ -612,7 +606,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
612
606
/// assert!(!(..=1.0).contains(&f32::NAN));
613
607
/// assert!(!(..=f32::NAN).contains(&0.5));
614
608
/// ```
615
- #[ unstable ( feature = "range_contains" , reason = "recently added as per RFC" , issue = "32311 ") ]
609
+ #[ stable ( feature = "range_contains" , since = "1.35.0 " ) ]
616
610
pub fn contains < U > ( & self , item : & U ) -> bool
617
611
where
618
612
Idx : PartialOrd < U > ,
@@ -714,14 +708,11 @@ pub trait RangeBounds<T: ?Sized> {
714
708
#[ stable( feature = "collections_range" , since = "1.28.0" ) ]
715
709
fn end_bound ( & self ) -> Bound < & T > ;
716
710
717
-
718
711
/// Returns `true` if `item` is contained in the range.
719
712
///
720
713
/// # Examples
721
714
///
722
715
/// ```
723
- /// #![feature(range_contains)]
724
- ///
725
716
/// use std::f32;
726
717
///
727
718
/// assert!( (3..5).contains(&4));
@@ -731,7 +722,7 @@ pub trait RangeBounds<T: ?Sized> {
731
722
/// assert!(!(0.0..1.0).contains(&f32::NAN));
732
723
/// assert!(!(0.0..f32::NAN).contains(&0.5));
733
724
/// 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 " ) ]
735
726
fn contains < U > ( & self , item : & U ) -> bool
736
727
where
737
728
T : PartialOrd < U > ,
@@ -741,9 +732,7 @@ pub trait RangeBounds<T: ?Sized> {
741
732
Included ( ref start) => * start <= item,
742
733
Excluded ( ref start) => * start < item,
743
734
Unbounded => true ,
744
- } )
745
- &&
746
- ( match self . end_bound ( ) {
735
+ } ) && ( match self . end_bound ( ) {
747
736
Included ( ref end) => item <= * end,
748
737
Excluded ( ref end) => item < * end,
749
738
Unbounded => true ,
@@ -819,15 +808,15 @@ impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
819
808
match * self {
820
809
( Included ( ref start) , _) => Included ( start) ,
821
810
( Excluded ( ref start) , _) => Excluded ( start) ,
822
- ( Unbounded , _) => Unbounded ,
811
+ ( Unbounded , _) => Unbounded ,
823
812
}
824
813
}
825
814
826
815
fn end_bound ( & self ) -> Bound < & T > {
827
816
match * self {
828
817
( _, Included ( ref end) ) => Included ( end) ,
829
818
( _, Excluded ( ref end) ) => Excluded ( end) ,
830
- ( _, Unbounded ) => Unbounded ,
819
+ ( _, Unbounded ) => Unbounded ,
831
820
}
832
821
}
833
822
}
0 commit comments