From 9b4007c3236305c3f693e76f98946ad3b7c3c8e3 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Mon, 1 Feb 2016 00:13:02 +0900 Subject: [PATCH 01/10] translate some sentence --- 1.6/ja/book/patterns.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index 8f4a7a43..1dc096a3 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -1,14 +1,20 @@ -% Patterns - -Patterns are quite common in Rust. We use them in [variable -bindings][bindings], [match statements][match], and other places, too. Let’s go -on a whirlwind tour of all of the things patterns can do! - +()[ + % Patterns +] +% パターン Patterns +()[Patterns are quite common in Rust.] +パターンはRustにおいて極めて一般的な方法です。 +()[We use them in [variable +bindings][bindings], [match statements][match], and other places, too.] +パターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 +()[Let’s go on a whirlwind tour of all of the things patterns can do!] +さあ、めくるめくパターンの旅を始めましょう! [bindings]: variable-bindings.html [match]: match.html -A quick refresher: you can match against literals directly, and `_` acts as an -‘any’ case: +()[A quick refresher: you can match against literals directly, and `_` acts as an +‘any’ case:] +簡単な復習: パターンはリテラルに対しては直接マッチさせることができます。また、`_`は'any'型として振る舞います。 ```rust let x = 1; From 8691eaca841695c1cb88730bed0a7bdcbb08f359 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Sun, 7 Feb 2016 22:55:29 +0900 Subject: [PATCH 02/10] translate in text --- 1.6/ja/book/patterns.md | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index 1dc096a3..06152629 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -6,7 +6,7 @@ パターンはRustにおいて極めて一般的な方法です。 ()[We use them in [variable bindings][bindings], [match statements][match], and other places, too.] -パターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 +パパターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 ()[Let’s go on a whirlwind tour of all of the things patterns can do!] さあ、めくるめくパターンの旅を始めましょう! [bindings]: variable-bindings.html @@ -28,9 +28,11 @@ match x { ``` This prints `one`. +これは `one` を表示します。 There’s one pitfall with patterns: like anything that introduces a new binding, they introduce shadowing. For example: +パターンには一つ落とし穴があります。新しいバインディングを導入すると、しばしば落とし穴がついてきます。例を見ましょう。 ```rust let x = 'x'; @@ -44,6 +46,7 @@ println!("x: {}", x) ``` This prints: +これの結果は、 ```text x: c c: c @@ -53,10 +56,12 @@ x: x In other words, `x =>` matches the pattern and introduces a new binding named `x` that’s in scope for the match arm. Because we already have a binding named `x`, this new `x` shadows it. - +説明すると、 `x =>` はパターンへのマッチだけでなく、パターンが参照出来る範囲で、 `x` という名前のバインディングを導入します。 # Multiple patterns You can match multiple patterns with `|`: +`|` を使うと、多重パターンマッチが導入出来ます。 + ```rust let x = 1; @@ -69,11 +74,13 @@ match x { ``` This prints `one or two`. +これは、`one or two` を出力します。 # Destructuring If you have a compound data type, like a [`struct`][struct], you can destructure it inside of a pattern: +例えば、[`struct`][struct]のようなデータ型を作成したいとき、パターンの内側のデータを分解することが出来ます。 ```rust struct Point { @@ -91,6 +98,7 @@ match origin { [struct]: structs.html We can use `:` to give a value a different name. +値に別の名前を付けたいときは、`:`を使うことが出来ます。 ```rust struct Point { @@ -106,6 +114,7 @@ match origin { ``` If we only care about some of the values, we don’t have to give them all names: +値のうちいくつかを扱いたい場合でも、値の全てに名前を付ける必要はありません。 ```rust struct Point { @@ -121,8 +130,10 @@ match origin { ``` This prints `x is 0`. +これは`x is 0`を出力します。 You can do this kind of match on any member, not just the first: +どのメンバーに対してもこの種のマッチを行うことが出来ます。たとえ最初ではなくても。 ```rust struct Point { @@ -138,9 +149,12 @@ match origin { ``` This prints `y is 0`. +これは`y is 0`を出力します。 This ‘destructuring’ behavior works on any compound data type, like [tuples][tuples] or [enums][enums]. +この「デストラクチャリング」と呼ばれる振る舞いは、[タプル][tuples]や[列挙型][enum]のような、構成されたデータ型で起こります。 + [tuples]: primitive-types.html#tuples [enums]: enums.html @@ -148,7 +162,10 @@ This ‘destructuring’ behavior works on any compound data type, like # Ignoring bindings You can use `_` in a pattern to disregard the type and value. +パターン内の型や値を無視するために`_`を使うことが出来ます。 + For example, here’s a `match` against a `Result`: +例として、`Result`に対して`match`を適用してみましょう。 ```rust # let some_value: Result = Err("There was an error"); @@ -161,9 +178,10 @@ match some_value { In the first arm, we bind the value inside the `Ok` variant to `value`. But in the `Err` arm, we use `_` to disregard the specific error, and just print a general error message. - +最初の部分では、`Ok`ヴァリアント内の値を`value`に結びつけています。しかし、`Err`部分ですと、特定のエラーを避けるために、また標準エラーメッセージを表示するために`_`を使っています。 `_` is valid in any pattern that creates a binding. This can be useful to ignore parts of a larger structure: +`_`はバインディングを伴うどんなパターンに於いても有効です。これは大きな構造の一部分を無視する際に有用です。 ```rust fn coordinate() -> (i32, i32, i32) { @@ -176,8 +194,9 @@ let (x, _, z) = coordinate(); Here, we bind the first and last element of the tuple to `x` and `z`, but ignore the middle element. - +ここでは、タプルの最初と最後の要素を`x`と`z`に結びつけています。 Similarly, you can use `..` in a pattern to disregard multiple values. +同様に、`..`でパターン内の複数の値を無視することが出来ます。 ```rust enum OptionalTuple { @@ -194,10 +213,12 @@ match x { ``` This prints `Got a tuple!`. +これは `Got a tuple!`を出力します。 # ref and ref mut If you want to get a [reference][ref], use the `ref` keyword: +もし[リファレンス][ref]を読みたいときは、`ref`キーワードを使いましょう。 ```rust let x = 5; @@ -208,12 +229,14 @@ match x { ``` This prints `Got a reference to 5`. +これは`Got a reference to 5`を出力します。 [ref]: references-and-borrowing.html Here, the `r` inside the `match` has the type `&i32`. In other words, the `ref` keyword _creates_ a reference, for use in the pattern. If you need a mutable reference, `ref mut` will work in the same way: +ここで、`match`内の`r`は`&i32`型を持っています。言い換えると、`ref`キーワードがリファレンスを _作ります_ 。 ```rust let mut x = 5; @@ -226,6 +249,7 @@ match x { # Ranges You can match a range of values with `...`: +`...`で値の幅のマッチを行うことが出来ます。 ```rust let x = 1; @@ -237,8 +261,9 @@ match x { ``` This prints `one through five`. - +これは`one through five`を出力します。 Ranges are mostly used with integers and `char`s: +レンジは大体、整数か`char`型で使われます。 ```rust let x = '💅'; @@ -251,10 +276,12 @@ match x { ``` This prints `something else`. +これは`something else`を出力します。 # Bindings You can bind values to names with `@`: +`@`で値を名前と結びつけることが出来ます。 ```rust let x = 1; @@ -267,6 +294,8 @@ match x { This prints `got a range element 1`. This is useful when you want to do a complicated match of part of a data structure: +これは`got a range element 1`を出力します。 +データ構造の一部に対する複雑なマッチが欲しいときに有用です。 ```rust #[derive(Debug)] @@ -283,9 +312,11 @@ match x { ``` This prints `Some("Steve")`: we’ve bound the inner `name` to `a`. - +これは`Some("Steve")`を出力します。内側の`name`を`a`に結びつけます。 If you use `@` with `|`, you need to make sure the name is bound in each part of the pattern: +もし`|`で`@`を使うときは、パターンのそれぞれの部分が名前と結びついているか確認する必要があります。 + ```rust let x = 5; @@ -299,6 +330,7 @@ match x { # Guards You can introduce ‘match guards’ with `if`: +`if`を使うことでマッチガードを導入することが出来ます。 ```rust enum OptionalInt { @@ -316,8 +348,10 @@ match x { ``` This prints `Got an int!`. +これは`Got an int!`を出力します。 If you’re using `if` with multiple patterns, the `if` applies to both sides: +多重パターンで`if`を使うと、`if`は両方に適用されます。 ```rust let x = 4; @@ -354,3 +388,4 @@ match x { ``` Patterns are very powerful. Make good use of them. +パターンはとても強力です。上手に使いましょう。 From ca919870171d9f853f70e7762aa771231184c086 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Sat, 13 Feb 2016 16:04:52 +0900 Subject: [PATCH 03/10] comment the english sentence out --- 1.6/ja/book/patterns.md | 115 ++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index 06152629..6eb28ab3 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -1,19 +1,19 @@ -()[ + % パターン Patterns -()[Patterns are quite common in Rust.] + パターンはRustにおいて極めて一般的な方法です。 -()[We use them in [variable -bindings][bindings], [match statements][match], and other places, too.] + パパターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 -()[Let’s go on a whirlwind tour of all of the things patterns can do!] + さあ、めくるめくパターンの旅を始めましょう! [bindings]: variable-bindings.html [match]: match.html -()[A quick refresher: you can match against literals directly, and `_` acts as an -‘any’ case:] + 簡単な復習: パターンはリテラルに対しては直接マッチさせることができます。また、`_`は'any'型として振る舞います。 ```rust @@ -27,11 +27,11 @@ match x { } ``` -This prints `one`. + これは `one` を表示します。 -There’s one pitfall with patterns: like anything that introduces a new binding, -they introduce shadowing. For example: + + パターンには一つ落とし穴があります。新しいバインディングを導入すると、しばしば落とし穴がついてきます。例を見ましょう。 ```rust @@ -45,7 +45,7 @@ match c { println!("x: {}", x) ``` -This prints: + これの結果は、 ```text @@ -53,13 +53,14 @@ x: c c: c x: x ``` -In other words, `x =>` matches the pattern and introduces a new binding named + 説明すると、 `x =>` はパターンへのマッチだけでなく、パターンが参照出来る範囲で、 `x` という名前のバインディングを導入します。 + # Multiple patterns -You can match multiple patterns with `|`: + `|` を使うと、多重パターンマッチが導入出来ます。 @@ -73,13 +74,13 @@ match x { } ``` -This prints `one or two`. + これは、`one or two` を出力します。 # Destructuring -If you have a compound data type, like a [`struct`][struct], you can destructure it -inside of a pattern: + 例えば、[`struct`][struct]のようなデータ型を作成したいとき、パターンの内側のデータを分解することが出来ます。 ```rust @@ -97,7 +98,7 @@ match origin { [struct]: structs.html -We can use `:` to give a value a different name. + 値に別の名前を付けたいときは、`:`を使うことが出来ます。 ```rust @@ -113,7 +114,7 @@ match origin { } ``` -If we only care about some of the values, we don’t have to give them all names: + 値のうちいくつかを扱いたい場合でも、値の全てに名前を付ける必要はありません。 ```rust @@ -129,10 +130,10 @@ match origin { } ``` -This prints `x is 0`. + これは`x is 0`を出力します。 -You can do this kind of match on any member, not just the first: + どのメンバーに対してもこの種のマッチを行うことが出来ます。たとえ最初ではなくても。 ```rust @@ -148,11 +149,11 @@ match origin { } ``` -This prints `y is 0`. + これは`y is 0`を出力します。 -This ‘destructuring’ behavior works on any compound data type, like -[tuples][tuples] or [enums][enums]. + この「デストラクチャリング」と呼ばれる振る舞いは、[タプル][tuples]や[列挙型][enum]のような、構成されたデータ型で起こります。 @@ -161,10 +162,10 @@ This ‘destructuring’ behavior works on any compound data type, like # Ignoring bindings -You can use `_` in a pattern to disregard the type and value. + パターン内の型や値を無視するために`_`を使うことが出来ます。 -For example, here’s a `match` against a `Result`: + 例として、`Result`に対して`match`を適用してみましょう。 ```rust @@ -175,12 +176,12 @@ match some_value { } ``` -In the first arm, we bind the value inside the `Ok` variant to `value`. But + 最初の部分では、`Ok`ヴァリアント内の値を`value`に結びつけています。しかし、`Err`部分ですと、特定のエラーを避けるために、また標準エラーメッセージを表示するために`_`を使っています。 -`_` is valid in any pattern that creates a binding. This can be useful to -ignore parts of a larger structure: + `_`はバインディングを伴うどんなパターンに於いても有効です。これは大きな構造の一部分を無視する際に有用です。 ```rust @@ -192,10 +193,10 @@ fn coordinate() -> (i32, i32, i32) { let (x, _, z) = coordinate(); ``` -Here, we bind the first and last element of the tuple to `x` and `z`, but -ignore the middle element. + ここでは、タプルの最初と最後の要素を`x`と`z`に結びつけています。 -Similarly, you can use `..` in a pattern to disregard multiple values. + 同様に、`..`でパターン内の複数の値を無視することが出来ます。 ```rust @@ -212,12 +213,12 @@ match x { } ``` -This prints `Got a tuple!`. + これは `Got a tuple!`を出力します。 # ref and ref mut -If you want to get a [reference][ref], use the `ref` keyword: + もし[リファレンス][ref]を読みたいときは、`ref`キーワードを使いましょう。 ```rust @@ -228,14 +229,14 @@ match x { } ``` -This prints `Got a reference to 5`. + これは`Got a reference to 5`を出力します。 [ref]: references-and-borrowing.html -Here, the `r` inside the `match` has the type `&i32`. In other words, the `ref` + ここで、`match`内の`r`は`&i32`型を持っています。言い換えると、`ref`キーワードがリファレンスを _作ります_ 。 ```rust @@ -248,7 +249,7 @@ match x { # Ranges -You can match a range of values with `...`: + `...`で値の幅のマッチを行うことが出来ます。 ```rust @@ -260,9 +261,9 @@ match x { } ``` -This prints `one through five`. + これは`one through five`を出力します。 -Ranges are mostly used with integers and `char`s: + レンジは大体、整数か`char`型で使われます。 ```rust @@ -275,12 +276,12 @@ match x { } ``` -This prints `something else`. + これは`something else`を出力します。 # Bindings -You can bind values to names with `@`: + `@`で値を名前と結びつけることが出来ます。 ```rust @@ -292,8 +293,8 @@ match x { } ``` -This prints `got a range element 1`. This is useful when you want to -do a complicated match of part of a data structure: + これは`got a range element 1`を出力します。 データ構造の一部に対する複雑なマッチが欲しいときに有用です。 @@ -311,10 +312,10 @@ match x { } ``` -This prints `Some("Steve")`: we’ve bound the inner `name` to `a`. + これは`Some("Steve")`を出力します。内側の`name`を`a`に結びつけます。 -If you use `@` with `|`, you need to make sure the name is bound in each part -of the pattern: + もし`|`で`@`を使うときは、パターンのそれぞれの部分が名前と結びついているか確認する必要があります。 @@ -329,7 +330,7 @@ match x { # Guards -You can introduce ‘match guards’ with `if`: + `if`を使うことでマッチガードを導入することが出来ます。 ```rust @@ -347,10 +348,10 @@ match x { } ``` -This prints `Got an int!`. + これは`Got an int!`を出力します。 -If you’re using `if` with multiple patterns, the `if` applies to both sides: + 多重パターンで`if`を使うと、`if`は両方に適用されます。 ```rust @@ -363,8 +364,8 @@ match x { } ``` -This prints `no`, because the `if` applies to the whole of `4 | 5`, and not to -just the `5`. In other words, the precedence of `if` behaves like this: + ```text (4 | 5) if y => ... @@ -378,8 +379,8 @@ not this: # Mix and Match -Whew! That’s a lot of different ways to match things, and they can all be -mixed and matched, depending on what you’re doing: + ```rust,ignore match x { @@ -387,5 +388,5 @@ match x { } ``` -Patterns are very powerful. Make good use of them. + パターンはとても強力です。上手に使いましょう。 From 7d2916c71c17549c5d2ae80ee5d36149d9e6cd92 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Sat, 13 Feb 2016 18:01:48 +0900 Subject: [PATCH 04/10] =?UTF-8?q?=E8=AA=A4=E5=AD=97=E3=81=A8=E6=9C=AA?= =?UTF-8?q?=E8=A8=B3=E9=83=A8=E5=88=86=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.6/ja/book/patterns.md | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index 6eb28ab3..dd5d4682 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -6,7 +6,7 @@ パターンはRustにおいて極めて一般的な方法です。 -パパターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 +パターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 さあ、めくるめくパターンの旅を始めましょう! [bindings]: variable-bindings.html @@ -58,7 +58,8 @@ x: x `x`, this new `x` shadows it. --> 説明すると、 `x =>` はパターンへのマッチだけでなく、パターンが参照出来る範囲で、 `x` という名前のバインディングを導入します。 -# Multiple patterns + +# 多重パターンマッチ `|` を使うと、多重パターンマッチが導入出来ます。 @@ -77,7 +78,8 @@ match x { これは、`one or two` を出力します。 -# Destructuring + +# デストラクチャ @@ -160,7 +162,8 @@ match origin { [tuples]: primitive-types.html#tuples [enums]: enums.html -# Ignoring bindings + +# バインディングの無視 パターン内の型や値を無視するために`_`を使うことが出来ます。 @@ -216,10 +219,11 @@ match x { これは `Got a tuple!`を出力します。 -# ref and ref mut + +# ref と ref mut -もし[リファレンス][ref]を読みたいときは、`ref`キーワードを使いましょう。 +もし[リファレンス][ref]を取得したいときは、`ref`キーワードを使いましょう。 ```rust let x = 5; @@ -247,7 +251,8 @@ match x { } ``` -# Ranges + +# レンジ `...`で値の幅のマッチを行うことが出来ます。 @@ -279,7 +284,8 @@ match x { これは`something else`を出力します。 -# Bindings + +# バインディング `@`で値を名前と結びつけることが出来ます。 @@ -328,7 +334,8 @@ match x { } ``` -# Guards + +# ガード `if`を使うことでマッチガードを導入することが出来ます。 @@ -366,22 +373,27 @@ match x { +これは`no`を出力します。なぜなら`if`は`4 | 5`全体に適用されるのであって、`5`単独に対してではないからです。つまり、`if`節は以下のように振舞います。 ```text (4 | 5) if y => ... ``` -not this: + +次のようには解釈されません。 ```text 4 | (5 if y) => ... ``` -# Mix and Match + +# ミックスとマッチ +さて、マッチにはまだ沢山の方法があります。やろうとしていることに依りますが、それらの方法を混ぜてマッチさせることも出来ます。 + ```rust,ignore match x { Foo { x: Some(ref name), y: None } => ... From 088b393b0ba493460e8350c844ba8ec2552c5c32 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Sun, 14 Feb 2016 01:00:34 +0900 Subject: [PATCH 05/10] fix 1st sentence and quote --- 1.6/ja/book/patterns.md | 54 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index dd5d4682..44cd860e 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -1,7 +1,7 @@ +% パターン Patterns -% パターン Patterns パターンはRustにおいて極めて一般的な方法です。 -簡単な復習: パターンはリテラルに対しては直接マッチさせることができます。また、`_`は'any'型として振る舞います。 +簡単な復習: パターンはリテラルに対しては直接マッチさせることができます。また、 `_` は「any」型として振る舞います。 ```rust let x = 1; @@ -62,7 +62,7 @@ x: x # 多重パターンマッチ -`|` を使うと、多重パターンマッチが導入出来ます。 + `|` を使うと、多重パターンマッチが導入出来ます。 ```rust @@ -76,7 +76,7 @@ match x { ``` -これは、`one or two` を出力します。 +これは、 `one or two` を出力します。 # デストラクチャ @@ -133,7 +133,7 @@ match origin { ``` -これは`x is 0`を出力します。 +これは `x is 0` を出力します。 どのメンバーに対してもこの種のマッチを行うことが出来ます。たとえ最初ではなくても。 @@ -152,7 +152,7 @@ match origin { ``` -これは`y is 0`を出力します。 +これは `y is 0` を出力します。 @@ -166,10 +166,10 @@ match origin { # バインディングの無視 -パターン内の型や値を無視するために`_`を使うことが出来ます。 +パターン内の型や値を無視するために `_` を使うことが出来ます。 -例として、`Result`に対して`match`を適用してみましょう。 +例として、 `Result` に対して `match` を適用してみましょう。 ```rust # let some_value: Result = Err("There was an error"); @@ -182,10 +182,10 @@ match some_value { -最初の部分では、`Ok`ヴァリアント内の値を`value`に結びつけています。しかし、`Err`部分ですと、特定のエラーを避けるために、また標準エラーメッセージを表示するために`_`を使っています。 +最初の部分では、 `Ok` ヴァリアント内の値を `value` に結びつけています。しかし、 `Err` 部分ですと、特定のエラーを避けるために、また標準エラーメッセージを表示するために `_` を使っています。 -`_`はバインディングを伴うどんなパターンに於いても有効です。これは大きな構造の一部分を無視する際に有用です。 + `_` はバインディングを伴うどんなパターンに於いても有効です。これは大きな構造の一部分を無視する際に有用です。 ```rust fn coordinate() -> (i32, i32, i32) { @@ -198,9 +198,9 @@ let (x, _, z) = coordinate(); -ここでは、タプルの最初と最後の要素を`x`と`z`に結びつけています。 +ここでは、タプルの最初と最後の要素を `x` と `z` に結びつけています。 -同様に、`..`でパターン内の複数の値を無視することが出来ます。 +同様に、 `..` でパターン内の複数の値を無視することが出来ます。 ```rust enum OptionalTuple { @@ -217,13 +217,13 @@ match x { ``` -これは `Got a tuple!`を出力します。 +これは `Got a tuple!` を出力します。 # ref と ref mut -もし[リファレンス][ref]を取得したいときは、`ref`キーワードを使いましょう。 +もし[リファレンス][ref]を取得したいときは、 `ref` キーワードを使いましょう。 ```rust let x = 5; @@ -234,14 +234,14 @@ match x { ``` -これは`Got a reference to 5`を出力します。 +これは `Got a reference to 5` を出力します。 [ref]: references-and-borrowing.html -ここで、`match`内の`r`は`&i32`型を持っています。言い換えると、`ref`キーワードがリファレンスを _作ります_ 。 +ここで、 `match` 内の `r` は `&i32` 型を持っています。言い換えると、 `ref` キーワードがリファレンスを _作ります_ 。 ```rust let mut x = 5; @@ -267,9 +267,9 @@ match x { ``` -これは`one through five`を出力します。 +これは `one through five` を出力します。 -レンジは大体、整数か`char`型で使われます。 +レンジは大体、整数か `char` 型で使われます。 ```rust let x = '💅'; @@ -282,13 +282,13 @@ match x { ``` -これは`something else`を出力します。 +これは `something else` を出力します。 # バインディング -`@`で値を名前と結びつけることが出来ます。 + `@` で値を名前と結びつけることが出来ます。 ```rust let x = 1; @@ -301,7 +301,7 @@ match x { -これは`got a range element 1`を出力します。 +これは `got a range element 1` を出力します。 データ構造の一部に対する複雑なマッチが欲しいときに有用です。 ```rust @@ -319,10 +319,10 @@ match x { ``` -これは`Some("Steve")`を出力します。内側の`name`を`a`に結びつけます。 +これは `Some("Steve")` を出力します。内側の `name` を `a` に結びつけます。 -もし`|`で`@`を使うときは、パターンのそれぞれの部分が名前と結びついているか確認する必要があります。 +もし `|` で `@` を使うときは、パターンのそれぞれの部分が名前と結びついているか確認する必要があります。 ```rust @@ -338,7 +338,7 @@ match x { # ガード -`if`を使うことでマッチガードを導入することが出来ます。 + `if` を使うことでマッチガードを導入することが出来ます。 ```rust enum OptionalInt { @@ -356,10 +356,10 @@ match x { ``` -これは`Got an int!`を出力します。 +これは `Got an int!` を出力します。 -多重パターンで`if`を使うと、`if`は両方に適用されます。 +多重パターンで `if` を使うと、 `if` は両方に適用されます。 ```rust let x = 4; @@ -373,7 +373,7 @@ match x { -これは`no`を出力します。なぜなら`if`は`4 | 5`全体に適用されるのであって、`5`単独に対してではないからです。つまり、`if`節は以下のように振舞います。 +これは `no` を出力します。なぜなら `if` は `4 | 5` 全体に適用されるのであって、 `5` 単独に対してではないからです。つまり、 `if` 節は以下のように振舞います。 ```text (4 | 5) if y => ... From 97b875d44ff4eb79c7f07de25ab964fab7638c5e Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Mon, 15 Feb 2016 23:31:13 +0900 Subject: [PATCH 06/10] fix some bugs in patterns.md --- 1.6/ja/book/patterns.md | 1 - 1 file changed, 1 deletion(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index 44cd860e..c715043a 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -391,7 +391,6 @@ just the `5`. In other words, the precedence of `if` behaves like this: --> - さて、マッチにはまだ沢山の方法があります。やろうとしていることに依りますが、それらの方法を混ぜてマッチさせることも出来ます。 ```rust,ignore From bb67563553df30263f86c48cef51919f188f64a3 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Mon, 15 Feb 2016 23:40:50 +0900 Subject: [PATCH 07/10] fix conflict --- TranslationTable.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TranslationTable.md b/TranslationTable.md index 4a490ef2..bfd4d8ce 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -107,6 +107,7 @@ | platform | プラットフォーム | pointer | ポインタ | process | プロセス +| range | レンジ | raw pointer | 生ポインタ | re-assignment | 再代入 | rebind | 再束縛 From 7941eaef5e35860b5659f7ff2f0c753b1759694f Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Mon, 15 Feb 2016 23:54:27 +0900 Subject: [PATCH 08/10] fix some bugs in patterns.md --- 1.6/ja/book/patterns.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index c715043a..643afe7f 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -6,7 +6,7 @@ パターンはRustにおいて極めて一般的な方法です。 -パターンは、[変数束縛][bindings]、[マッチ宣言][match]、などで使われています。 +パターンは、[変数束縛][bindings]、[マッチ文][match]、などで使われています。 さあ、めくるめくパターンの旅を始めましょう! [bindings]: variable-bindings.html @@ -31,8 +31,7 @@ match x { これは `one` を表示します。 - -パターンには一つ落とし穴があります。新しいバインディングを導入すると、しばしば落とし穴がついてきます。例を見ましょう。 +パターンには一つ落とし穴があります。新しい束縛を導入すると、他の束縛を導入するものと同じように、シャドーイングをします。 ```rust let x = 'x'; @@ -46,7 +45,7 @@ println!("x: {}", x) ``` -これの結果は、 +これの結果は以下のようになります。 ```text x: c c: c @@ -56,13 +55,13 @@ x: x -説明すると、 `x =>` はパターンへのマッチだけでなく、パターンが参照出来る範囲で、 `x` という名前のバインディングを導入します。 +説明すると、 `x =>` はパターンへのマッチだけでなく、マッチの腕内で有効な `x` という名前の束縛を導入します。 -# 多重パターンマッチ +# 複式パターン - `|` を使うと、多重パターンマッチが導入出来ます。 + `|` を使うと、複式パターンが導入出来ます。 ```rust @@ -83,7 +82,7 @@ match x { -例えば、[`struct`][struct]のようなデータ型を作成したいとき、パターンの内側のデータを分解することが出来ます。 +例えば、[`struct`][struct]のようなデータ型を作成したいとき、パターン内でデータを分配することが出来ます。 ```rust struct Point { @@ -101,7 +100,7 @@ match origin { [struct]: structs.html -値に別の名前を付けたいときは、`:`を使うことが出来ます。 +値に別の名前を付けたいときは、 `:` を使うことが出来ます。 ```rust struct Point { @@ -117,7 +116,7 @@ match origin { ``` -値のうちいくつかを扱いたい場合でも、値の全てに名前を付ける必要はありません。 +値のうちいくつかを扱いたい場合は、値の全てに名前を付ける必要はありません。 ```rust struct Point { @@ -163,7 +162,7 @@ match origin { [enums]: enums.html -# バインディングの無視 +# 束縛の無視 パターン内の型や値を無視するために `_` を使うことが出来ます。 @@ -185,7 +184,7 @@ a general error message. --> 最初の部分では、 `Ok` ヴァリアント内の値を `value` に結びつけています。しかし、 `Err` 部分ですと、特定のエラーを避けるために、また標準エラーメッセージを表示するために `_` を使っています。 - `_` はバインディングを伴うどんなパターンに於いても有効です。これは大きな構造の一部分を無視する際に有用です。 + `_` は束縛を伴うどんなパターンに於いても有効です。これは大きな構造の一部分を無視する際に有用です。 ```rust fn coordinate() -> (i32, i32, i32) { @@ -255,7 +254,7 @@ match x { # レンジ -`...`で値の幅のマッチを行うことが出来ます。 + `...` で値のレンジのマッチを行うことが出来ます。 ```rust let x = 1; @@ -285,7 +284,7 @@ match x { これは `something else` を出力します。 -# バインディング +# 束縛 `@` で値を名前と結びつけることが出来ます。 @@ -359,7 +358,7 @@ match x { これは `Got an int!` を出力します。 -多重パターンで `if` を使うと、 `if` は両方に適用されます。 +複式パターンで `if` を使うと、 `if` は両方に適用されます。 ```rust let x = 4; @@ -387,7 +386,7 @@ just the `5`. In other words, the precedence of `if` behaves like this: --> ``` -# ミックスとマッチ +# 混ぜてマッチ From c932292e983d221463c5614bf3a75ae691413111 Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Tue, 16 Feb 2016 00:00:39 +0900 Subject: [PATCH 09/10] add guard to TranslationTable --- TranslationTable.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TranslationTable.md b/TranslationTable.md index bfd4d8ce..950ae726 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -61,6 +61,7 @@ | generic parameter | ジェネリックパラメータ | generics | ジェネリクス | growable | 伸張可能 +| guard | ガード | hash | ハッシュ | identifier | 識別子 | immutable | イミュータブル From e7920903a0f7e6b87db9f15a556853d60fbd19ea Mon Sep 17 00:00:00 2001 From: Shingo Onobori Date: Sat, 20 Feb 2016 18:00:15 +0900 Subject: [PATCH 10/10] =?UTF-8?q?=E8=A8=B3=E3=81=97=E5=BF=98=E3=82=8C?= =?UTF-8?q?=E3=82=92=E8=A8=B3=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.6/ja/book/patterns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1.6/ja/book/patterns.md b/1.6/ja/book/patterns.md index 643afe7f..b587af1a 100644 --- a/1.6/ja/book/patterns.md +++ b/1.6/ja/book/patterns.md @@ -55,7 +55,7 @@ x: x -説明すると、 `x =>` はパターンへのマッチだけでなく、マッチの腕内で有効な `x` という名前の束縛を導入します。 +説明すると、 `x =>` はパターンへのマッチだけでなく、マッチの腕内で有効な `x` という名前の束縛を導入します。なぜなら既に `x` は束縛されており、この新しい `x` はそれを覆い隠します。 # 複式パターン