Skip to content

Commit dea84bc

Browse files
committed
Add Rust ranges to the overview
1 parent d0f37ac commit dea84bc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

proposals/open-ended-ranges.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ println(eqivalent) // 1..1.9999999999999998
6565
- Swift: `...` end-inclusive range, `..<` end-exclusive, supports one-sided ranges
6666
- Ruby: `..` end-inclusive range, `...` end-exclusive, supports one-sided ranges
6767
- Groovy: `..` end-inclusive range, `..<` end-exclusive, `<..` start-exclusive, `<..<` both bounds-exclusive range
68-
68+
- Rust: `..=` end-inclusive range, `..` end-exclusive, supports one-sided ranges
6969

7070
### Libraries for representing ranges
7171

@@ -86,6 +86,16 @@ println(eqivalent) // 1..1.9999999999999998
8686
The base protocol provides operations of checking whether the range contains a value and slicing a collection
8787
(i.e. producing the closed range of indices of the collection with the matching index type that are contained in the range).
8888

89+
- Rust provides 6 structs in the standard library to represent ranges, varying by their boundness and inclusiveness of the end bound:
90+
[`Range`](https://doc.rust-lang.org/std/ops/struct.Range.html), [`RangeInclusive`](https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html),
91+
[`RangeFrom`](https://doc.rust-lang.org/std/ops/struct.RangeFrom.html),
92+
[`RangeTo`](https://doc.rust-lang.org/std/ops/struct.RangeTo.html), [`RangeToInclusive`](https://doc.rust-lang.org/std/ops/struct.RangeTo.html),
93+
[`RangeFull`](https://doc.rust-lang.org/std/ops/struct.RangeTo.html).
94+
95+
There's also a crate that provides a more generic [`GenericRange`](https://docs.rs/ranges/latest/ranges/struct.GenericRange.html) implementation
96+
that covers all of the above range variants and allows to express other type of ranges, like one with an excluded start bound.
97+
98+
8999
- [kotlin-statistics](https://github.com/thomasnield/kotlin-statistics/blob/master/src/main/kotlin/org/nield/kotlinstatistics/range)
90100
library provides the base `Range` type and individual types for each combination of included/excluded bounds:
91101
`OpenRange`, `OpenClosedRange`, `ClosedOpenRange`, `XClosedRange`.

0 commit comments

Comments
 (0)