4 ms·
Rust tries to be conservative with its semantics. You can always create your own range type and implement a deref/from for it to convert it to Rust range.
by adamnemecek 6y ago
Rust tries to be conservative with its semantics. You can always create your own range type and implement a deref/from for it to convert it to Rust range.
- swsieber 6y agoA well known wart that can be worked around is still a wart.
- CydeWeys 6y agoIt seems like in this case Rust actually failed to act conservatively in its semantics, by allowing ranges on overly generic types in a way that doesn't make sense.
- hobofan 6y agoI think the problem here is more that the semantics are documented in the "documentation", but are contrary to the intuition derived from the semantics in the type system. `.contains()` is only implemented for `Range<Idx: PartialOrd>`, which to me implies that when checking whether a value is contained in the Range, it has enough knowledge about the ordering of numbers that it should be able to still do a bounds check on reversely ordered numbers.
- cryptonector 6y agoAnd yet Range is broken. TFA is 100% convincing.