Skip to content

Commit 6a2304f

Browse files
ソースコード中のコメントの訳を、併記する形に変更
1 parent b9673e1 commit 6a2304f

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,43 +126,24 @@ For example:
126126

127127
例えば以下のようになります。
128128

129-
<!--
130129
```rust
131130
macro_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` が `|` にマッチしないので、以下のマクロは正常に動きます:
138138
my_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:
143143
macro_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
}

0 commit comments

Comments
 (0)