6
6
>   ;  ; | _ RangeFromExpr_
7
7
>   ;  ; | _ RangeToExpr_
8
8
>   ;  ; | _ RangeFullExpr_
9
+ >   ;  ; | _ RangeInclusiveExpr_
10
+ >   ;  ; | _ RangeToInclusiveExpr_
9
11
>
10
12
> _ RangeExpr_ :
11
13
>   ;  ; [ _ Expression_ ] ` .. ` [ _ Expression_ ]
18
20
>
19
21
> _ RangeFullExpr_ :
20
22
>   ;  ; ` .. `
23
+ >
24
+ > _ RangeExpr_ :
25
+ >   ;  ; [ _ Expression_ ] ` ..= ` [ _ Expression_ ]
26
+ >
27
+ > _ RangeToExpr_ :
28
+ >   ;  ; ` ..= ` [ _ Expression_ ]
21
29
22
- The ` .. ` operator will construct an object of one of the ` std::ops::Range ` (or
23
- ` core::ops::Range ` ) variants, according to the following table:
30
+ The ` .. ` and ` ..= ` operators will construct an object of one of the
31
+ ` std::ops::Range ` (or ` core::ops::Range ` ) variants, according to the following
32
+ table:
24
33
25
34
| Production | Syntax | Type | Range |
26
35
| ------------------------| ---------------| ------------------------------| -----------------------|
27
36
| _ RangeExpr_ | start` .. ` end | [ std::ops::Range] | start &le ; x < ; end |
28
37
| _ RangeFromExpr_ | start` .. ` | [ std::ops::RangeFrom] | start &le ; x |
29
38
| _ RangeToExpr_ | ` .. ` end | [ std::ops::RangeTo] | x < ; end |
30
39
| _ RangeFullExpr_ | ` .. ` | [ std::ops::RangeFull] | - |
40
+ | _ RangeInclusiveExpr_ | start` ..= ` end | [ std::ops::RangeInclusive] | start &le ; x &le ; end |
41
+ | _ RangeToInclusiveExpr_ | ` ..= ` end | [ std::ops::RangeToInclusive] | x &le ; end |
31
42
32
43
Examples:
33
44
@@ -36,6 +47,8 @@ Examples:
36
47
3 .. ; // std::ops::RangeFrom
37
48
.. 4 ; // std::ops::RangeTo
38
49
.. ; // std::ops::RangeFull
50
+ 5 ..= 6 ; // std::ops::RangeInclusive
51
+ ..= 7 ; // std::ops::RangeToInclusive
39
52
```
40
53
41
54
The following expressions are equivalent.
@@ -57,7 +70,9 @@ for i in 1..11 {
57
70
58
71
[ _Expression_ ] : expressions.html
59
72
60
- [ std::ops::Range ] : https://doc.rust-lang.org/std/ops/struct.Range.html
61
- [ std::ops::RangeFrom ] : https://doc.rust-lang.org/std/ops/struct.RangeFrom.html
62
- [ std::ops::RangeTo ] : https://doc.rust-lang.org/std/ops/struct.RangeTo.html
63
- [ std::ops::RangeFull ] : https://doc.rust-lang.org/std/ops/struct.RangeFull.html
73
+ [ std::ops::Range ] : https://doc.rust-lang.org/std/ops/struct.Range.html
74
+ [ std::ops::RangeFrom ] : https://doc.rust-lang.org/std/ops/struct.RangeFrom.html
75
+ [ std::ops::RangeTo ] : https://doc.rust-lang.org/std/ops/struct.RangeTo.html
76
+ [ std::ops::RangeFull ] : https://doc.rust-lang.org/std/ops/struct.RangeFull.html
77
+ [ std::ops::RangeInclusive ] : https://doc.rust-lang.org/std/ops/struct.RangeInclusive.html
78
+ [ std::ops::RangeToInclusive ] : https://doc.rust-lang.org/std/ops/struct.RangeToInclusive.html
0 commit comments