We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b62b352 commit 9fd79a3Copy full SHA for 9fd79a3
library/core/src/ops/range.rs
@@ -495,7 +495,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
495
Idx: PartialOrd<U>,
496
U: ?Sized + PartialOrd<Idx>,
497
{
498
- !self.exhausted && <Self as RangeBounds<Idx>>::contains(self, item)
+ <Self as RangeBounds<Idx>>::contains(self, item)
499
}
500
501
/// Returns `true` if the range contains no items.
@@ -891,7 +891,13 @@ impl<T> RangeBounds<T> for RangeInclusive<T> {
891
Included(&self.start)
892
893
fn end_bound(&self) -> Bound<&T> {
894
- Included(&self.end)
+ if self.exhausted {
895
+ // When the iterator is exhausted, we usually have start == end,
896
+ // but we want the range to appear empty, containing nothing.
897
+ Excluded(&self.end)
898
+ } else {
899
+ Included(&self.end)
900
+ }
901
902
903
0 commit comments