File tree 2 files changed +50
-0
lines changed
src/doc/unstable-book/src/language-features
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ` exclusive_range_pattern `
2
+
3
+ The tracking issue for this feature is: [ #37854 ] .
4
+
5
+
6
+ [ #67264 ] : https://github.com/rust-lang/rust/issues/67264
7
+ [ #37854 ] : https://github.com/rust-lang/rust/issues/37854
8
+ -----
9
+
10
+ The ` exclusive_range_pattern ` feature allows non-inclusive range
11
+ patterns (` 0..10 ` ) to be used in appropriate pattern matching
12
+ contexts. It also can be combined with ` #![feature(half_open_range_patterns] `
13
+ to be able to use RangeTo patterns (` ..10 ` ).
14
+
15
+ It also enabled RangeFrom patterns but that has since been
16
+ stabilized.
17
+
18
+ ``` rust
19
+ #![feature(exclusive_range_pattern)]
20
+ match x {
21
+ 0 .. 10 => println! (" single digit" ),
22
+ 10 => println! (" ten isn't part of the above range" ),
23
+ _ => println! (" nor is everything else." )
24
+ }
25
+ ```
Original file line number Diff line number Diff line change
1
+ # ` half_open_range_patterns `
2
+
3
+ The tracking issue for this feature is: [ #67264 ]
4
+ It is part of the ` #![exclusive_range_pattern] ` feature,
5
+ tracked at [ #37854 ] .
6
+
7
+ [ #67264 ] : https://github.com/rust-lang/rust/issues/67264
8
+ [ #37854 ] : https://github.com/rust-lang/rust/issues/37854
9
+ -----
10
+
11
+ The ` half_open_range_patterns ` feature allows RangeTo patterns
12
+ (` ..10 ` ) to be used in appropriate pattern matching contexts.
13
+ This requires also enabling the ` exclusive_range_pattern ` feature.
14
+
15
+ It also enabled RangeFrom patterns but that has since been
16
+ stabilized.
17
+
18
+ ``` rust
19
+ #![feature(half_open_range_patterns)]
20
+ #![feature(exclusive_range_pattern)]
21
+ match x {
22
+ .. 10 => println! (" got it" ),
23
+ 0 => println! (" zilch" )
24
+ }
25
+ ```
You can’t perform that action at this time.
0 commit comments