# \`...\` vs \`..=\` for inclusive ranges

**URL:** <https://internals.rust-lang.org/t/vs-for-inclusive-ranges/1539>\
**Category:** ideas (deprecated)\
**Created:** [February 4, 2015, 1:23pm UTC](https://internals.rust-lang.org/t/vs-for-inclusive-ranges/1539 "2015-02-04T13:23:56Z")\
**Posts on this page:** 1\
**Showing post:** 106

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [December 1, 2016, 9:44am UTC](https://internals.rust-lang.org/t/vs-for-inclusive-ranges/1539/106 "2016-12-01T09:44:22Z")

</div>

> [@norru](#):
>
> Is 0 \<= RangeFull \<= 5 a valid construct?

It'd work in C++ (overload `operator <=(FullRange, T)` to return `RangeToInclusive<T>`), but `PartialOrd` says `<=` can only return bool, via `partial_cmp` returning `Option<Ordering>`, so I assume it can't work in Rust. (And PartialOrd requires PartialEq, so it'd also allow silliness like `4 == .. == 2`.) I assume it'd be completely doable as a macro, though. Then you could even make `range!(0 <= r)` turn `RangeTo(5)` into `Range(0, 5)`.

Let me also plug the comment I posted on the other thread about ranges. **TL/DR** : From an algorithmic perspective, I think all `std` should provide is the Range [a,b) where b is 'reachable' from a by zero-or-more-but-finite applications of a successor function (aka, roughly, a ≤ b). Going beyond that feels like we're making an interval library, which is a totally different thing, and the current range is no better than a pair.

> [@Representation of generalized ranges](https://internals.rust-lang.org/t/representation-of-generalized-ranges/3792/5):
>
> Has it been considered whether some kind of bound makes sense? I guess back-compat blocks a hard requirement, but it feels weird to me that let x = f64::NAN..f64::NAN; is totally fine. What does that range even mean? (The docs just refer to contains, which that value can’t instantiate.) Part of my brain wants it to be a “valid range” in an Elements of Programming iterator range sense, so it’s not PartialOrd. Maybe it’s some kind of often-only-checked-in-debug SameSubdomain? A place to hook…

---

_[View the full topic](https://internals.rust-lang.org/t/vs-for-inclusive-ranges/1539)._
