@@ -105,24 +105,24 @@ match x {
105105
106106This code prints ` one or two ` .
107107
108- ### Matching Ranges of Values with ` ... `
108+ ### Matching Ranges of Values with ` ..= `
109109
110- The ` ... ` syntax allows us to match to an inclusive range of values. In the
110+ The ` ..= ` syntax allows us to match to an inclusive range of values. In the
111111following code, when a pattern matches any of the values within the range, that
112112arm will execute:
113113
114114``` rust
115115let x = 5 ;
116116
117117match x {
118- 1 ... 5 => println! (" one through five" ),
118+ 1 ..= 5 => println! (" one through five" ),
119119 _ => println! (" something else" ),
120120}
121121```
122122
123123If ` x ` is 1, 2, 3, 4, or 5, the first arm will match. This syntax is more
124124convenient than using the ` | ` operator to express the same idea; instead of
125- ` 1... 5 ` , we would have to specify ` 1 | 2 | 3 | 4 | 5 ` if we used ` | ` .
125+ ` 1..= 5 ` , we would have to specify ` 1 | 2 | 3 | 4 | 5 ` if we used ` | ` .
126126Specifying a range is much shorter, especially if we want to match, say, any
127127number between 1 and 1,000!
128128
@@ -136,8 +136,8 @@ Here is an example using ranges of `char` values:
136136let x = 'c' ;
137137
138138match x {
139- 'a' ... 'j' => println! (" early ASCII letter" ),
140- 'k' ... 'z' => println! (" late ASCII letter" ),
139+ 'a' ..= 'j' => println! (" early ASCII letter" ),
140+ 'k' ..= 'z' => println! (" late ASCII letter" ),
141141 _ => println! (" something else" ),
142142}
143143```
@@ -783,7 +783,7 @@ were applied only to the final value in the list of values specified using the
783783The * at* operator (` @ ` ) lets us create a variable that holds a value at the
784784same time we’re testing that value to see whether it matches a pattern. Listing
78578518-29 shows an example where we want to test that a ` Message::Hello ` ` id ` field
786- is within the range ` 3... 7 ` . But we also want to bind the value to the variable
786+ is within the range ` 3..= 7 ` . But we also want to bind the value to the variable
787787` id_variable ` so we can use it in the code associated with the arm. We could
788788name this variable ` id ` , the same as the field, but for this example we’ll use
789789a different name.
@@ -796,10 +796,10 @@ enum Message {
796796let msg = Message :: Hello { id : 5 };
797797
798798match msg {
799- Message :: Hello { id : id_variable @ 3 ... 7 } => {
799+ Message :: Hello { id : id_variable @ 3 ..= 7 } => {
800800 println! (" Found an id in range: {}" , id_variable )
801801 },
802- Message :: Hello { id : 10 ... 12 } => {
802+ Message :: Hello { id : 10 ..= 12 } => {
803803 println! (" Found an id in another range" )
804804 },
805805 Message :: Hello { id } => {
@@ -812,7 +812,7 @@ match msg {
812812while also testing it</span >
813813
814814This example will print ` Found an id in range: 5 ` . By specifying `id_variable
815- @` before the range ` 3... 7`, we’re capturing whatever value matched the range
815+ @` before the range ` 3..= 7`, we’re capturing whatever value matched the range
816816while also testing that the value matched the range pattern.
817817
818818In the second arm, where we only have a range specified in the pattern, the code
0 commit comments