In dtolnay/syn#1373 I noticed an inconsistency between how ranges are described in the reference vs how the compiler uses the same terminology.
Rustc has the following enum which distinguishes .. vs ..= in range patterns and expressions:
https://github.com/rust-lang/rust/blob/1.67.0/compiler/rustc_ast/src/ast.rs#L1323-L1328
pub enum RangeLimits {
/// Inclusive at the beginning, exclusive at the end (..)
HalfOpen,
/// Inclusive at the beginning and end (..=)
Closed,
}
Ranges in rustc are effectively (Option<Expr>, RangeLimits, Option<Expr>).
Meanwhile a different approach is currently taken by the Rust Reference: https://doc.rust-lang.org/1.67.0/reference/patterns.html#range-patterns
RangePattern :
InclusiveRangePattern | HalfOpenRangePattern
InclusiveRangePattern :
RangePatternBound `..=` RangePatternBound
HalfOpenRangePattern :
RangePatternBound `..` | `..=` RangePatternBound
Notice how it has a ..= pattern which it refers to as half open, even though ..= is never considered half open in rustc.
| range |
rustc terminology |
reference terminology |
lo.. |
half open |
half open |
..=hi |
closed (opposite of half open) |
half open (!) |
lo..=hi |
closed |
inclusive |
Do we know whether one of these uses of the "half open" terminology is more preferred? Might we reach agreement about which of rustc or the reference should be changed?
In dtolnay/syn#1373 I noticed an inconsistency between how ranges are described in the reference vs how the compiler uses the same terminology.
Rustc has the following enum which distinguishes
..vs..=in range patterns and expressions:https://github.com/rust-lang/rust/blob/1.67.0/compiler/rustc_ast/src/ast.rs#L1323-L1328
Ranges in rustc are effectively
(Option<Expr>, RangeLimits, Option<Expr>).Meanwhile a different approach is currently taken by the Rust Reference: https://doc.rust-lang.org/1.67.0/reference/patterns.html#range-patterns
Notice how it has a
..=pattern which it refers to as half open, even though..=is never considered half open in rustc.lo....=hilo..=hiDo we know whether one of these uses of the "half open" terminology is more preferred? Might we reach agreement about which of rustc or the reference should be changed?