File tree Expand file tree Collapse file tree 1 file changed +3
-22
lines changed
Expand file tree Collapse file tree 1 file changed +3
-22
lines changed Original file line number Diff line number Diff line change @@ -126,43 +126,24 @@ For example:
126126
127127例えば以下のようになります。
128128
129- <!--
130129``` rust
131130macro_rules! my_macro {
132131 ($ x : pat | $ y : pat ) => {
133132 // TODO: implementation
134- }
133+ // TODO: 実装
135134}
136135
137136// This macro works in Rust 2018 since `$x:pat` does not match against `|`:
137+ // Rust 2018 では、`$x:pat` が `|` にマッチしないので、以下のマクロは正常に動きます:
138138my_macro! (1 | 2 );
139139
140140// In Rust 2021 however, the `$_:pat` fragment matches `|` and is not allowed
141141// to be followed by a `|`. To make sure this macro still works in Rust 2021
142142// change the macro to the following:
143143macro_rules! my_macro {
144144 ($ x : pat_param | $ y : pat ) => { // <- this line is different
145+ // この行を変えた
145146 // TODO: implementation
146- }
147- }
148- ```
149- -->
150-
151- ``` rust
152- macro_rules! my_macro {
153- ($ x : pat | $ y : pat ) => {
154- // TODO: 実装
155- }
156- }
157-
158- // Rust 2018 では、`$x:pat` が `|` にマッチしないので、以下のマクロは正常に動きます:
159- my_macro! (1 | 2 );
160-
161- // 一方 Rust 2021 では、`$_:pat` フラグメントは `|` にもマッチし、
162- // `|` が後続してはいけなくなりました。
163- // Rust 2021 でもマクロが動作するためには、マクロを以下のように変更しなくてはなりません:
164- macro_rules! my_macro {
165- ($ x : pat_param | $ y : pat ) => { // <- この行を変えた
166147 // TODO: 実装
167148 }
168149}
You can’t perform that action at this time.
0 commit comments