File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,18 @@ pub struct RangeInclusive<T> {
31
31
pub end : T ,
32
32
pub finished : bool ,
33
33
}
34
+
35
+ pub struct RangeToInclusive <T > {
36
+ pub end : T ,
37
+ }
34
38
```
35
39
36
40
Writing ` a...b ` in an expression desugars to `std::ops::RangeInclusive
37
- { start: a, end: b, finished: false }`.
41
+ { start: a, end: b, finished: false }` . Writing ` ...b` in an
42
+ expression desugars to ` std::ops::RangeToInclusive { end: b } ` .
38
43
39
- This struct implements the standard traits (` Clone ` , ` Debug ` etc.),
40
- and implements ` Iterator ` . The ` finished ` field is to allow the
44
+ ` RangeInclusive ` implements the standard traits (` Clone ` , ` Debug `
45
+ etc.), and implements ` Iterator ` . The ` finished ` field is to allow the
41
46
` Iterator ` implementation to work without hacks (see Alternatives).
42
47
43
48
The use of ` ... ` in a pattern remains as testing for inclusion
@@ -59,7 +64,9 @@ semantically.)
59
64
The ` ... ` vs. ` .. ` distinction is the exact inversion of Ruby's syntax.
60
65
61
66
Having an extra field in a language-level desugaring, catering to one
62
- library use-case is a little non-"hygienic".
67
+ library use-case is a little non-"hygienic". It is especially strange
68
+ that the field isn't consistent across the different ` ... `
69
+ desugarings.
63
70
64
71
# Alternatives
65
72
You can’t perform that action at this time.
0 commit comments