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_.
28122812(["a", "b"])[10]; // panics
28132813```
28142814
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+
28152842### Unary operator expressions
28162843
28172844Rust defines three unary operators. They are all written as prefix operators,
You can’t perform that action at this time.
0 commit comments