diff options
| author | Steven Malis <smmalis37@gmail.com> | 2018-04-10 19:26:25 -0700 |
|---|---|---|
| committer | Steven Malis <smmalis37@gmail.com> | 2018-04-10 19:41:10 -0700 |
| commit | 51f24ec7f01b6a636750baff5ab5a12ec6bfe6cd (patch) | |
| tree | 675cec1c4c3dbfb5a153fa779b3601ce748ca1eb | |
| parent | 249dc9e5cd5abaea710345fcabca815e5e59eec6 (diff) | |
Add symmetric requirement of PartialOrd.
| -rw-r--r-- | src/libcore/ops/range.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index 868308cafd1..6f3e3b50885 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -119,7 +119,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> { pub fn contains<U>(&self, item: &U) -> bool where Idx: PartialOrd<U>, - U: ?Sized, + U: ?Sized + PartialOrd<Idx>, { <Self as RangeBounds<Idx>>::contains(self, item) } @@ -212,7 +212,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> { pub fn contains<U>(&self, item: &U) -> bool where Idx: PartialOrd<U>, - U: ?Sized, + U: ?Sized + PartialOrd<Idx>, { <Self as RangeBounds<Idx>>::contains(self, item) } @@ -293,7 +293,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> { pub fn contains<U>(&self, item: &U) -> bool where Idx: PartialOrd<U>, - U: ?Sized, + U: ?Sized + PartialOrd<Idx>, { <Self as RangeBounds<Idx>>::contains(self, item) } @@ -369,7 +369,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> { pub fn contains<U>(&self, item: &U) -> bool where Idx: PartialOrd<U>, - U: ?Sized, + U: ?Sized + PartialOrd<Idx>, { <Self as RangeBounds<Idx>>::contains(self, item) } @@ -487,7 +487,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> { pub fn contains<U>(&self, item: &U) -> bool where Idx: PartialOrd<U>, - U: ?Sized, + U: ?Sized + PartialOrd<Idx>, { <Self as RangeBounds<Idx>>::contains(self, item) } @@ -612,7 +612,7 @@ pub trait RangeBounds<T: ?Sized> { fn contains<U>(&self, item: &U) -> bool where T: PartialOrd<U>, - U: ?Sized, + U: ?Sized + PartialOrd<T>, { (match self.start() { Included(ref start) => *start <= item, @@ -621,8 +621,8 @@ pub trait RangeBounds<T: ?Sized> { }) && (match self.end() { - Included(ref end) => *end >= item, - Excluded(ref end) => *end > item, + Included(ref end) => item <= *end, + Excluded(ref end) => item < *end, Unbounded => true, }) } |
