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 @@ -2812,6 +2812,33 @@ _panicked state_.
2812
2812
(["a", "b"])[10]; // panics
2813
2813
```
2814
2814
2815
+ ### Range expressions
2816
+
2817
+ ``` {.ebnf .gram}
2818
+ range_expr : expr ".." expr |
2819
+ expr ".." |
2820
+ ".." expr |
2821
+ ".." ;
2822
+ ```
2823
+
2824
+ The ` .. ` operator will construct an object of one of the ` std::ops::Range ` variants.
2825
+
2826
+ ```
2827
+ 1..2; // std::ops::Range
2828
+ 3..; // std::ops::RangeFrom
2829
+ ..4; // std::ops::RangeTo
2830
+ ..; // std::ops::RangeFull
2831
+ ```
2832
+
2833
+ The following expressions are equivalent.
2834
+
2835
+ ```
2836
+ let x = std::ops::Range {start: 0, end: 10};
2837
+ let y = 0..10;
2838
+
2839
+ assert_eq!(x,y);
2840
+ ```
2841
+
2815
2842
### Unary operator expressions
2816
2843
2817
2844
Rust defines three unary operators. They are all written as prefix operators,
You can’t perform that action at this time.
0 commit comments