Skip to content

Commit 1440f30

Browse files
committed
stabilize RangeBounds collections_range rust-lang#30877
rename RangeBounds::start() -> start_bound() rename RangeBounds::end() -> end_bound()
1 parent b4463d7 commit 1440f30

File tree

7 files changed

+68
-100
lines changed

7 files changed

+68
-100
lines changed

src/liballoc/btree/map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ fn range_search<BorrowType, K, V, Q: ?Sized, R: RangeBounds<Q>>(
18341834
Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::Edge>)
18351835
where Q: Ord, K: Borrow<Q>
18361836
{
1837-
match (range.start(), range.end()) {
1837+
match (range.start_bound(), range.end_bound()) {
18381838
(Excluded(s), Excluded(e)) if s==e =>
18391839
panic!("range start and end are equal and excluded in BTreeMap"),
18401840
(Included(s), Included(e)) |
@@ -1852,7 +1852,7 @@ fn range_search<BorrowType, K, V, Q: ?Sized, R: RangeBounds<Q>>(
18521852
let mut diverged = false;
18531853

18541854
loop {
1855-
let min_edge = match (min_found, range.start()) {
1855+
let min_edge = match (min_found, range.start_bound()) {
18561856
(false, Included(key)) => match search::search_linear(&min_node, key) {
18571857
(i, true) => { min_found = true; i },
18581858
(i, false) => i,
@@ -1866,7 +1866,7 @@ fn range_search<BorrowType, K, V, Q: ?Sized, R: RangeBounds<Q>>(
18661866
(true, Excluded(_)) => 0,
18671867
};
18681868

1869-
let max_edge = match (max_found, range.end()) {
1869+
let max_edge = match (max_found, range.end_bound()) {
18701870
(false, Included(key)) => match search::search_linear(&max_node, key) {
18711871
(i, true) => { max_found = true; i+1 },
18721872
(i, false) => i,

src/liballoc/string.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1493,12 +1493,12 @@ impl String {
14931493
// Because the range removal happens in Drop, if the Drain iterator is leaked,
14941494
// the removal will not happen.
14951495
let len = self.len();
1496-
let start = match range.start() {
1496+
let start = match range.start_bound() {
14971497
Included(&n) => n,
14981498
Excluded(&n) => n + 1,
14991499
Unbounded => 0,
15001500
};
1501-
let end = match range.end() {
1501+
let end = match range.end_bound() {
15021502
Included(&n) => n + 1,
15031503
Excluded(&n) => n,
15041504
Unbounded => len,
@@ -1551,12 +1551,12 @@ impl String {
15511551
// Replace_range does not have the memory safety issues of a vector Splice.
15521552
// of the vector version. The data is just plain bytes.
15531553

1554-
match range.start() {
1554+
match range.start_bound() {
15551555
Included(&n) => assert!(self.is_char_boundary(n)),
15561556
Excluded(&n) => assert!(self.is_char_boundary(n + 1)),
15571557
Unbounded => {},
15581558
};
1559-
match range.end() {
1559+
match range.end_bound() {
15601560
Included(&n) => assert!(self.is_char_boundary(n + 1)),
15611561
Excluded(&n) => assert!(self.is_char_boundary(n)),
15621562
Unbounded => {},

src/liballoc/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1166,12 +1166,12 @@ impl<T> Vec<T> {
11661166
// the hole, and the vector length is restored to the new length.
11671167
//
11681168
let len = self.len();
1169-
let start = match range.start() {
1169+
let start = match range.start_bound() {
11701170
Included(&n) => n,
11711171
Excluded(&n) => n + 1,
11721172
Unbounded => 0,
11731173
};
1174-
let end = match range.end() {
1174+
let end = match range.end_bound() {
11751175
Included(&n) => n + 1,
11761176
Excluded(&n) => n,
11771177
Unbounded => len,

src/liballoc/vec_deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -980,12 +980,12 @@ impl<T> VecDeque<T> {
980980
// and the head/tail values will be restored correctly.
981981
//
982982
let len = self.len();
983-
let start = match range.start() {
983+
let start = match range.start_bound() {
984984
Included(&n) => n,
985985
Excluded(&n) => n + 1,
986986
Unbounded => 0,
987987
};
988-
let end = match range.end() {
988+
let end = match range.end_bound() {
989989
Included(&n) => n + 1,
990990
Excluded(&n) => n,
991991
Unbounded => len,

src/libcore/ops/range.rs

+53-85
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,12 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
588588
/// `Bound`s are range endpoints:
589589
///
590590
/// ```
591-
/// #![feature(collections_range)]
592-
///
593591
/// use std::ops::Bound::*;
594592
/// use std::ops::RangeBounds;
595593
///
596-
/// assert_eq!((..100).start(), Unbounded);
597-
/// assert_eq!((1..12).start(), Included(&1));
598-
/// assert_eq!((1..12).end(), Excluded(&12));
594+
/// assert_eq!((..100).start_bound(), Unbounded);
595+
/// assert_eq!((1..12).start_bound(), Included(&1));
596+
/// assert_eq!((1..12).end_bound(), Excluded(&12));
599597
/// ```
600598
///
601599
/// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
@@ -632,9 +630,7 @@ pub enum Bound<T> {
632630
Unbounded,
633631
}
634632

635-
#[unstable(feature = "collections_range",
636-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
637-
issue = "30877")]
633+
#[stable(feature = "collections_range", since = "1.28.0")]
638634
/// `RangeBounds` is implemented by Rust's built-in range types, produced
639635
/// by range syntax like `..`, `a..`, `..b` or `c..d`.
640636
pub trait RangeBounds<T: ?Sized> {
@@ -645,17 +641,16 @@ pub trait RangeBounds<T: ?Sized> {
645641
/// # Examples
646642
///
647643
/// ```
648-
/// #![feature(collections_range)]
649-
///
650644
/// # fn main() {
651645
/// use std::ops::Bound::*;
652646
/// use std::ops::RangeBounds;
653647
///
654-
/// assert_eq!((..10).start(), Unbounded);
655-
/// assert_eq!((3..10).start(), Included(&3));
648+
/// assert_eq!((..10).start_bound(), Unbounded);
649+
/// assert_eq!((3..10).start_bound(), Included(&3));
656650
/// # }
657651
/// ```
658-
fn start(&self) -> Bound<&T>;
652+
#[stable(feature = "collections_range", since = "1.28.0")]
653+
fn start_bound(&self) -> Bound<&T>;
659654

660655
/// End index bound.
661656
///
@@ -664,17 +659,16 @@ pub trait RangeBounds<T: ?Sized> {
664659
/// # Examples
665660
///
666661
/// ```
667-
/// #![feature(collections_range)]
668-
///
669662
/// # fn main() {
670663
/// use std::ops::Bound::*;
671664
/// use std::ops::RangeBounds;
672665
///
673-
/// assert_eq!((3..).end(), Unbounded);
674-
/// assert_eq!((3..10).end(), Excluded(&10));
666+
/// assert_eq!((3..).end_bound(), Unbounded);
667+
/// assert_eq!((3..10).end_bound(), Excluded(&10));
675668
/// # }
676669
/// ```
677-
fn end(&self) -> Bound<&T>;
670+
#[stable(feature = "collections_range", since = "1.28.0")]
671+
fn end_bound(&self) -> Bound<&T>;
678672

679673

680674
/// Returns `true` if `item` is contained in the range.
@@ -699,13 +693,13 @@ pub trait RangeBounds<T: ?Sized> {
699693
T: PartialOrd<U>,
700694
U: ?Sized + PartialOrd<T>,
701695
{
702-
(match self.start() {
696+
(match self.start_bound() {
703697
Included(ref start) => *start <= item,
704698
Excluded(ref start) => *start < item,
705699
Unbounded => true,
706700
})
707701
&&
708-
(match self.end() {
702+
(match self.end_bound() {
709703
Included(ref end) => item <= *end,
710704
Excluded(ref end) => item < *end,
711705
Unbounded => true,
@@ -715,91 +709,77 @@ pub trait RangeBounds<T: ?Sized> {
715709

716710
use self::Bound::{Excluded, Included, Unbounded};
717711

718-
#[unstable(feature = "collections_range",
719-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
720-
issue = "30877")]
712+
#[stable(feature = "collections_range", since = "1.28.0")]
721713
impl<T: ?Sized> RangeBounds<T> for RangeFull {
722-
fn start(&self) -> Bound<&T> {
714+
fn start_bound(&self) -> Bound<&T> {
723715
Unbounded
724716
}
725-
fn end(&self) -> Bound<&T> {
717+
fn end_bound(&self) -> Bound<&T> {
726718
Unbounded
727719
}
728720
}
729721

730-
#[unstable(feature = "collections_range",
731-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
732-
issue = "30877")]
722+
#[stable(feature = "collections_range", since = "1.28.0")]
733723
impl<T> RangeBounds<T> for RangeFrom<T> {
734-
fn start(&self) -> Bound<&T> {
724+
fn start_bound(&self) -> Bound<&T> {
735725
Included(&self.start)
736726
}
737-
fn end(&self) -> Bound<&T> {
727+
fn end_bound(&self) -> Bound<&T> {
738728
Unbounded
739729
}
740730
}
741731

742-
#[unstable(feature = "collections_range",
743-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
744-
issue = "30877")]
732+
#[stable(feature = "collections_range", since = "1.28.0")]
745733
impl<T> RangeBounds<T> for RangeTo<T> {
746-
fn start(&self) -> Bound<&T> {
734+
fn start_bound(&self) -> Bound<&T> {
747735
Unbounded
748736
}
749-
fn end(&self) -> Bound<&T> {
737+
fn end_bound(&self) -> Bound<&T> {
750738
Excluded(&self.end)
751739
}
752740
}
753741

754-
#[unstable(feature = "collections_range",
755-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
756-
issue = "30877")]
742+
#[stable(feature = "collections_range", since = "1.28.0")]
757743
impl<T> RangeBounds<T> for Range<T> {
758-
fn start(&self) -> Bound<&T> {
744+
fn start_bound(&self) -> Bound<&T> {
759745
Included(&self.start)
760746
}
761-
fn end(&self) -> Bound<&T> {
747+
fn end_bound(&self) -> Bound<&T> {
762748
Excluded(&self.end)
763749
}
764750
}
765751

766-
#[unstable(feature = "collections_range",
767-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
768-
issue = "30877")]
752+
#[stable(feature = "collections_range", since = "1.28.0")]
769753
impl<T> RangeBounds<T> for RangeInclusive<T> {
770-
fn start(&self) -> Bound<&T> {
754+
fn start_bound(&self) -> Bound<&T> {
771755
Included(&self.start)
772756
}
773-
fn end(&self) -> Bound<&T> {
757+
fn end_bound(&self) -> Bound<&T> {
774758
Included(&self.end)
775759
}
776760
}
777761

778-
#[unstable(feature = "collections_range",
779-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
780-
issue = "30877")]
762+
#[stable(feature = "collections_range", since = "1.28.0")]
781763
impl<T> RangeBounds<T> for RangeToInclusive<T> {
782-
fn start(&self) -> Bound<&T> {
764+
fn start_bound(&self) -> Bound<&T> {
783765
Unbounded
784766
}
785-
fn end(&self) -> Bound<&T> {
767+
fn end_bound(&self) -> Bound<&T> {
786768
Included(&self.end)
787769
}
788770
}
789771

790-
#[unstable(feature = "collections_range",
791-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
792-
issue = "30877")]
772+
#[stable(feature = "collections_range", since = "1.28.0")]
793773
impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
794-
fn start(&self) -> Bound<&T> {
774+
fn start_bound(&self) -> Bound<&T> {
795775
match *self {
796776
(Included(ref start), _) => Included(start),
797777
(Excluded(ref start), _) => Excluded(start),
798778
(Unbounded, _) => Unbounded,
799779
}
800780
}
801781

802-
fn end(&self) -> Bound<&T> {
782+
fn end_bound(&self) -> Bound<&T> {
803783
match *self {
804784
(_, Included(ref end)) => Included(end),
805785
(_, Excluded(ref end)) => Excluded(end),
@@ -808,75 +788,63 @@ impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
808788
}
809789
}
810790

811-
#[unstable(feature = "collections_range",
812-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
813-
issue = "30877")]
791+
#[stable(feature = "collections_range", since = "1.28.0")]
814792
impl<'a, T: ?Sized + 'a> RangeBounds<T> for (Bound<&'a T>, Bound<&'a T>) {
815-
fn start(&self) -> Bound<&T> {
793+
fn start_bound(&self) -> Bound<&T> {
816794
self.0
817795
}
818796

819-
fn end(&self) -> Bound<&T> {
797+
fn end_bound(&self) -> Bound<&T> {
820798
self.1
821799
}
822800
}
823801

824-
#[unstable(feature = "collections_range",
825-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
826-
issue = "30877")]
802+
#[stable(feature = "collections_range", since = "1.28.0")]
827803
impl<'a, T> RangeBounds<T> for RangeFrom<&'a T> {
828-
fn start(&self) -> Bound<&T> {
804+
fn start_bound(&self) -> Bound<&T> {
829805
Included(self.start)
830806
}
831-
fn end(&self) -> Bound<&T> {
807+
fn end_bound(&self) -> Bound<&T> {
832808
Unbounded
833809
}
834810
}
835811

836-
#[unstable(feature = "collections_range",
837-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
838-
issue = "30877")]
812+
#[stable(feature = "collections_range", since = "1.28.0")]
839813
impl<'a, T> RangeBounds<T> for RangeTo<&'a T> {
840-
fn start(&self) -> Bound<&T> {
814+
fn start_bound(&self) -> Bound<&T> {
841815
Unbounded
842816
}
843-
fn end(&self) -> Bound<&T> {
817+
fn end_bound(&self) -> Bound<&T> {
844818
Excluded(self.end)
845819
}
846820
}
847821

848-
#[unstable(feature = "collections_range",
849-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
850-
issue = "30877")]
822+
#[stable(feature = "collections_range", since = "1.28.0")]
851823
impl<'a, T> RangeBounds<T> for Range<&'a T> {
852-
fn start(&self) -> Bound<&T> {
824+
fn start_bound(&self) -> Bound<&T> {
853825
Included(self.start)
854826
}
855-
fn end(&self) -> Bound<&T> {
827+
fn end_bound(&self) -> Bound<&T> {
856828
Excluded(self.end)
857829
}
858830
}
859831

860-
#[unstable(feature = "collections_range",
861-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
862-
issue = "30877")]
832+
#[stable(feature = "collections_range", since = "1.28.0")]
863833
impl<'a, T> RangeBounds<T> for RangeInclusive<&'a T> {
864-
fn start(&self) -> Bound<&T> {
834+
fn start_bound(&self) -> Bound<&T> {
865835
Included(self.start)
866836
}
867-
fn end(&self) -> Bound<&T> {
837+
fn end_bound(&self) -> Bound<&T> {
868838
Included(self.end)
869839
}
870840
}
871841

872-
#[unstable(feature = "collections_range",
873-
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
874-
issue = "30877")]
842+
#[stable(feature = "collections_range", since = "1.28.0")]
875843
impl<'a, T> RangeBounds<T> for RangeToInclusive<&'a T> {
876-
fn start(&self) -> Bound<&T> {
844+
fn start_bound(&self) -> Bound<&T> {
877845
Unbounded
878846
}
879-
fn end(&self) -> Bound<&T> {
847+
fn end_bound(&self) -> Bound<&T> {
880848
Included(self.end)
881849
}
882850
}

src/librustc_data_structures/array_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ impl<A: Array> ArrayVec<A> {
119119
// the hole, and the vector length is restored to the new length.
120120
//
121121
let len = self.len();
122-
let start = match range.start() {
122+
let start = match range.start_bound() {
123123
Included(&n) => n,
124124
Excluded(&n) => n + 1,
125125
Unbounded => 0,
126126
};
127-
let end = match range.end() {
127+
let end = match range.end_bound() {
128128
Included(&n) => n + 1,
129129
Excluded(&n) => n,
130130
Unbounded => len,

0 commit comments

Comments
 (0)