Expand description
Range (§4.11, ADR-059).
a..b is the integers from a up to but not including b; a..=b includes
b. Both forms build the same payload — an inclusiveness flag would be a
second way to spell one set of values, so the constructor normalizes ..=
into its half-open equivalent and the payload holds only what it iterates.
A descending range is empty, not a countdown. for i in 5..0 runs zero
times, matching Python and Rust; a range that silently reversed direction
would compute a different loop than the one that was written half the time it
appeared. RangeVal::new is where that is decided, once: an end below
start is stored as start, so len is a subtraction and cannot be
negative.
The payload is two plain i64s. Nothing is owned, nothing is traced, and the
bounds are immutable once built — which is what makes a Range hashable and
usable as a Map key (ADR-057 D4: the rule is mutability).
Structs§
- Range
Val - The
Rangepayload: a half-open[start, end)interval overInt.
Statics§
- RANGE
- Descriptor for
Range(§4.11). Equatable and hashable over its two bounds, and orderable over them too — aRangecan be aMapkey (its bounds cannot change after it is stored), so a container has to be able to put one in a deterministic sequence (ADR-138).a..b < c..din source is still Y006; that iscapability::supports_ord’s question. - RANGE_
PAYLOAD Range’s payload handle: the two-i64value, not a scalar.