Skip to content

Commit 124453e

Browse files
SimonSapinManishearth
authored andcommitted
impl RangeBounds<T> for Range{,From,To,Inclusive,ToInclusive}<&T>
1 parent 16d3ba1 commit 124453e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/libcore/ops/range.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,3 +646,63 @@ impl<'a, T: ?Sized + 'a> RangeBounds<T> for (Bound<&'a T>, Bound<&'a T>) {
646646
self.1
647647
}
648648
}
649+
650+
#[unstable(feature = "collections_range",
651+
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
652+
issue = "30877")]
653+
impl<'a, T> RangeBounds<T> for RangeFrom<&'a T> {
654+
fn start(&self) -> Bound<&T> {
655+
Included(self.start)
656+
}
657+
fn end(&self) -> Bound<&T> {
658+
Unbounded
659+
}
660+
}
661+
662+
#[unstable(feature = "collections_range",
663+
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
664+
issue = "30877")]
665+
impl<'a, T> RangeBounds<T> for RangeTo<&'a T> {
666+
fn start(&self) -> Bound<&T> {
667+
Unbounded
668+
}
669+
fn end(&self) -> Bound<&T> {
670+
Excluded(self.end)
671+
}
672+
}
673+
674+
#[unstable(feature = "collections_range",
675+
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
676+
issue = "30877")]
677+
impl<'a, T> RangeBounds<T> for Range<&'a T> {
678+
fn start(&self) -> Bound<&T> {
679+
Included(self.start)
680+
}
681+
fn end(&self) -> Bound<&T> {
682+
Excluded(self.end)
683+
}
684+
}
685+
686+
#[unstable(feature = "collections_range",
687+
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
688+
issue = "30877")]
689+
impl<'a, T> RangeBounds<T> for RangeInclusive<&'a T> {
690+
fn start(&self) -> Bound<&T> {
691+
Included(self.start)
692+
}
693+
fn end(&self) -> Bound<&T> {
694+
Included(self.end)
695+
}
696+
}
697+
698+
#[unstable(feature = "collections_range",
699+
reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
700+
issue = "30877")]
701+
impl<'a, T> RangeBounds<T> for RangeToInclusive<&'a T> {
702+
fn start(&self) -> Bound<&T> {
703+
Unbounded
704+
}
705+
fn end(&self) -> Bound<&T> {
706+
Included(self.end)
707+
}
708+
}

0 commit comments

Comments
 (0)