File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -2806,6 +2806,33 @@ _panicked state_.
2806
2806
(["a", "b"])[10]; // panics
2807
2807
```
2808
2808
2809
+ ### Range expressions
2810
+
2811
+ ``` {.ebnf .gram}
2812
+ range_expr : expr ".." expr |
2813
+ expr ".." |
2814
+ ".." expr |
2815
+ ".." ;
2816
+ ```
2817
+
2818
+ The ` .. ` operator will construct an object of one of the ` std::ops::Range ` variants.
2819
+
2820
+ ```
2821
+ 1..2; // std::ops::Range
2822
+ 3..; // std::ops::RangeFrom
2823
+ ..4; // std::ops::RangeTo
2824
+ ..; // std::ops::RangeFull
2825
+ ```
2826
+
2827
+ The following expressions are equivalent.
2828
+
2829
+ ```
2830
+ let x = std::ops::Range {start: 0, end: 10};
2831
+ let y = 0..10;
2832
+
2833
+ assert_eq!(x,y);
2834
+ ```
2835
+
2809
2836
### Unary operator expressions
2810
2837
2811
2838
Rust defines three unary operators. They are all written as prefix operators,
You can’t perform that action at this time.
0 commit comments