`range_bounds_is_empty` https://github.com/rust-lang/rust/issues/137300 This is correct for integers, but unsound for arbitrary `T`, so unlikely to be stabilized.
(range: &impl RangeBounds<u64>)
| 1049 | // This is correct for integers, but unsound for arbitrary `T`, so unlikely to |
| 1050 | // be stabilized. |
| 1051 | fn range_is_empty(range: &impl RangeBounds<u64>) -> bool { |
| 1052 | use std::ops::Bound::*; |
| 1053 | |
| 1054 | #[rustfmt::skip] |
| 1055 | let not_empty = match (range.start_bound(), range.end_bound()) { |
| 1056 | (Unbounded, _) | (_, Unbounded) => true, |
| 1057 | (Included(start), Excluded(end)) |
| 1058 | | (Excluded(start), Included(end)) |
| 1059 | | (Excluded(start), Excluded(end)) => start < end, |
| 1060 | (Included(start), Included(end)) => start <= end, |
| 1061 | }; |
| 1062 | |
| 1063 | !not_empty |
| 1064 | } |
| 1065 | |
| 1066 | #[cfg(test)] |
| 1067 | mod tests { |
no test coverage detected
searching dependent graphs…