Skip to content

Commit d332de8

Browse files
Apply suggestions from code review
Co-authored-by: Tatsuya Kawano <tatsuya@hibaridb.org>
1 parent 6a2304f commit d332de8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/rust-2021/or-patterns-macro-rules.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ that one still wishes to match pattern fragments followed by a `|`, the fragment
7575
has been added to retain the older behavior.
7676
-->
7777

78-
Rust 2021 では、`$_:pat` フラグメントに `|` そのものが後続することはできません
79-
パターンフラグメントに `|` が後続するものにマッチさせたいような場合は、新しく追加された `:pat_param` が過去と同じ挙動を示すようになっています。
78+
Rust 2021 では、`$_:pat` フラグメントに `|` そのものを続けることはできません
79+
パターンフラグメントに `|` が続いてるものにマッチさせたいような場合は、新しく追加された `:pat_param` が過去と同じ挙動を示すようになっています。
8080

8181
<!--
8282
It's important to remember that editions are _per crate_, so the only relevant edition is the edition
@@ -131,6 +131,7 @@ macro_rules! my_macro {
131131
($x:pat | $y:pat) => {
132132
// TODO: implementation
133133
// TODO: 実装
134+
}
134135
}
135136

136137
// This macro works in Rust 2018 since `$x:pat` does not match against `|`:
@@ -140,6 +141,9 @@ my_macro!(1 | 2);
140141
// In Rust 2021 however, the `$_:pat` fragment matches `|` and is not allowed
141142
// to be followed by a `|`. To make sure this macro still works in Rust 2021
142143
// change the macro to the following:
144+
// 一方 Rust 2021 では、`$_:pat` フラグメントは `|` にもマッチし、
145+
// `|` が続くのは許されなくなりました。
146+
// Rust 2021 でもマクロが動作するためには、マクロを以下のように変更しなくてはなりません:
143147
macro_rules! my_macro {
144148
($x:pat_param | $y:pat) => { // <- this line is different
145149
// この行を変えた

0 commit comments

Comments
 (0)