From cd1b835fe51818170b2687d4759c67a82df5f015 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Wed, 27 Jan 2016 19:04:16 +0900 Subject: [PATCH 01/12] start translating variable bindings --- 1.6/ja/book/variable-bindings.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index f3a5d1dd..fec364d1 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -1,4 +1,5 @@ -% Variable Bindings +% 変数束縛 + Virtually every non-'Hello World’ Rust program uses *variable bindings*. They bind some value to a name, so it can be used later. `let` is From 1a2cad831d05b1fc938b6afd2c0fa642985c59dc Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Thu, 28 Jan 2016 10:17:10 +0900 Subject: [PATCH 02/12] progress --- 1.6/ja/book/variable-bindings.md | 87 ++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index fec364d1..11b0b3a4 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -1,9 +1,15 @@ % 変数束縛 -Virtually every non-'Hello World’ Rust program uses *variable bindings*. They -bind some value to a name, so it can be used later. `let` is -used to introduce a binding, just like this: + + + +事実上全ての「Hello World」でないRustのプログラムは *変数束縛*を使っています。 +変数束縛は何らかの値を名前へと束縛するので、後でその値を使えます。 +このように、`let`が束縛を導入するのに使われています。 + +> 訳注: 普通、束縛というときは名前を値へと束縛しますが、ドキュメントでは逆になっています。 +> Rustでは他の言語と違って1つの値に対して1つの名前が対応するのであえてこう書いてるのかもしれません。 ```rust fn main() { @@ -11,52 +17,77 @@ fn main() { } ``` -Putting `fn main() {` in each example is a bit tedious, so we’ll leave that out -in the future. If you’re following along, make sure to edit your `main()` -function, rather than leaving it off. Otherwise, you’ll get an error. + + + +例で毎回`fn main() {`と書くのは長ったらしいのでこれ以後は省略します。 +もし試しながら読んでいるのならそのまま書くのではなくちゃんと`main()`関数の中身を編集するようにしてください、そうしないとエラーになります。 -# Patterns + +# パターン + + + + In many languages, a variable binding would be called a *variable*, but Rust’s variable bindings have a few tricks up their sleeves. For example the left-hand side of a `let` expression is a ‘[pattern][pattern]’, not just a variable name. This means we can do things like: +多くの言語では変数束縛は *変数* と呼ばれるでしょうが、Rustの変数束縛は多少皮を被せてあります。 +例えば、`let`の左側の式は「[パターン][pattern]」であって、ただの変数名ではありません。 +これはこのようなことが出来るということです。 + ```rust let (x, y) = (1, 2); ``` -After this expression is evaluated, `x` will be one, and `y` will be two. -Patterns are really powerful, and have [their own section][pattern] in the -book. We don’t need those features for now, so we’ll just keep this in the back -of our minds as we go forward. + + + + +パターン式が評価されたあと、`x`は1になり、`y`は2になります。 +パターンは本当に強力で、本書には[パターンのセクション][pattern]もあります。 +今のところこの機能は必要ないので頭の片隅に留めておいてだけいて下さい。 [pattern]: patterns.html -# Type annotations + +# 型アノテーション -Rust is a statically typed language, which means that we specify our types up -front, and they’re checked at compile time. So why does our first example -compile? Well, Rust has this thing called ‘type inference’. If it can figure -out what the type of something is, Rust doesn’t require you to actually type it -out. + + + + + +Rustは静的な型付言語であり、前もって型を与えておいて、それがコンパイル時に検査されます。 +じゃあなぜ最初の例はコンパイルが通るのでしょう?ええと、Rustには「型推論」と呼ばれるものがあります。 +型推論が型が何であるか判断出来るなら、型を書く必要はなくなります。 -We can add the type if we want to, though. Types come after a colon (`:`): + +書きたいなら型を書くことも出来ます。型はコロン(`:`)のあとに書きます。 ```rust let x: i32 = 5; ``` -If I asked you to read this out loud to the rest of the class, you’d say “`x` -is a binding with the type `i32` and the value `five`.” - -In this case we chose to represent `x` as a 32-bit signed integer. Rust has -many different primitive integer types. They begin with `i` for signed integers -and `u` for unsigned integers. The possible integer sizes are 8, 16, 32, and 64 -bits. - -In future examples, we may annotate the type in a comment. The examples will -look like this: + + +これをクラスのみんなに聞こえるように声に出して読むなら、「`x`は型`i32`を持つ束縛で、値は`五`である。」となります。 + + + + + +この場合`x`を32bit符号付き整数として表現することを選びました。 +Rustには多くのプリミティブな整数型があります。プリミティブな整数型は符号付き型は`i`、符号無し型は`u`から始まります。 +整数型として可能なサイズは8、16、32、64です。 + + + +以後の例では型はコンメントで注釈することにします。 +先の例はこのようになります。 ```rust fn main() { From 4fa2d5f6bbb682a9f41f952657f3bcd374386146 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Thu, 28 Jan 2016 10:21:56 +0900 Subject: [PATCH 03/12] up to type annotations --- 1.6/ja/book/variable-bindings.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index 11b0b3a4..32195eb3 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -95,13 +95,14 @@ fn main() { } ``` -Note the similarities between this annotation and the syntax you use with -`let`. Including these kinds of comments is not idiomatic Rust, but we'll -occasionally include them to help you understand what the types that Rust -infers are. + + + + +この注釈と`let`の時に使う記法の類似性に留意して下さい。 +このようなコメントを書くのはRust的ではありませんが、時折理解の手助けのためにRustが推論する型をコメントで注釈します。 # Mutability - By default, bindings are *immutable*. This code will not compile: ```rust,ignore From 301318d42018a64480a597a8d31322fbe2e44d05 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Tue, 2 Feb 2016 00:41:02 +0900 Subject: [PATCH 04/12] up to initializing variable --- 1.6/ja/book/variable-bindings.md | 147 +++++++++++++++++++------------ 1 file changed, 89 insertions(+), 58 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index 32195eb3..e6c1c847 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -6,7 +6,7 @@ 事実上全ての「Hello World」でないRustのプログラムは *変数束縛*を使っています。 変数束縛は何らかの値を名前へと束縛するので、後でその値を使えます。 -このように、`let`が束縛を導入するのに使われています。 +このように、 `let` が束縛を導入するのに使われています。 > 訳注: 普通、束縛というときは名前を値へと束縛しますが、ドキュメントでは逆になっています。 > Rustでは他の言語と違って1つの値に対して1つの名前が対応するのであえてこう書いてるのかもしれません。 @@ -20,8 +20,8 @@ fn main() { -例で毎回`fn main() {`と書くのは長ったらしいのでこれ以後は省略します。 -もし試しながら読んでいるのならそのまま書くのではなくちゃんと`main()`関数の中身を編集するようにしてください、そうしないとエラーになります。 +例で毎回 `fn main() {` と書くのは長ったらしいのでこれ以後は省略します。 +もし試しながら読んでいるのならそのまま書くのではなくちゃんと `main()` 関数の中身を編集するようにしてください、そうしないとエラーになります。 # パターン @@ -30,13 +30,8 @@ fn main() { -In many languages, a variable binding would be called a *variable*, but Rust’s -variable bindings have a few tricks up their sleeves. For example the -left-hand side of a `let` expression is a ‘[pattern][pattern]’, not just a -variable name. This means we can do things like: - 多くの言語では変数束縛は *変数* と呼ばれるでしょうが、Rustの変数束縛は多少皮を被せてあります。 -例えば、`let`の左側の式は「[パターン][pattern]」であって、ただの変数名ではありません。 +例えば、 `let` の左側の式は「[パターン][pattern]」であって、ただの変数名ではありません。 これはこのようなことが出来るということです。 ```rust @@ -47,7 +42,7 @@ let (x, y) = (1, 2); -パターン式が評価されたあと、`x`は1になり、`y`は2になります。 +パターン式が評価されたあと、 `x` は1になり、 `y` は2になります。 パターンは本当に強力で、本書には[パターンのセクション][pattern]もあります。 今のところこの機能は必要ないので頭の片隅に留めておいてだけいて下さい。 @@ -74,14 +69,14 @@ let x: i32 = 5; -これをクラスのみんなに聞こえるように声に出して読むなら、「`x`は型`i32`を持つ束縛で、値は`五`である。」となります。 +これをクラスのみんなに聞こえるように声に出して読むなら、「 `x` は型 `i32` を持つ束縛で、値は `五` である。」となります。 -この場合`x`を32bit符号付き整数として表現することを選びました。 -Rustには多くのプリミティブな整数型があります。プリミティブな整数型は符号付き型は`i`、符号無し型は`u`から始まります。 +この場合 `x` を32bit符号付き整数として表現することを選びました。 +Rustには多くのプリミティブな整数型があります。プリミティブな整数型は符号付き型は `i` 、符号無し型は `u` から始まります。 整数型として可能なサイズは8、16、32、64です。 @@ -99,18 +94,21 @@ fn main() { -この注釈と`let`の時に使う記法の類似性に留意して下さい。 +この注釈と `let` の時に使う記法の類似性に留意して下さい。 このようなコメントを書くのはRust的ではありませんが、時折理解の手助けのためにRustが推論する型をコメントで注釈します。 -# Mutability -By default, bindings are *immutable*. This code will not compile: + +# 可変性 + +デフォルトで、 束縛は *イミュータブル* です。このコードのコンパイルは通りません。 ```rust,ignore let x = 5; x = 10; ``` -It will give you this error: + +次のようなエラーが出ます。 ```text error: re-assignment of immutable variable `x` @@ -118,32 +116,49 @@ error: re-assignment of immutable variable `x` ^~~~~~~ ``` -If you want a binding to be mutable, you can use `mut`: +> 訳注: +> ``` +> エラー: イミュータブルな変数 `x` に最代入しています +> ``` + + + +束縛をミュータブルにしたいなら、`mut`が使えます。 ```rust let mut x = 5; // mut x: i32 x = 10; ``` -There is no single reason that bindings are immutable by default, but we can -think about it through one of Rust’s primary focuses: safety. If you forget to -say `mut`, the compiler will catch it, and let you know that you have mutated -something you may not have intended to mutate. If bindings were mutable by -default, the compiler would not be able to tell you this. If you _did_ intend -mutation, then the solution is quite easy: add `mut`. - -There are other good reasons to avoid mutable state when possible, but they’re -out of the scope of this guide. In general, you can often avoid explicit -mutation, and so it is preferable in Rust. That said, sometimes, mutation is -what you need, so it’s not verboten. - -# Initializing bindings - -Rust variable bindings have one more aspect that differs from other languages: -bindings are required to be initialized with a value before you're allowed to -use them. - -Let’s try it out. Change your `src/main.rs` file to look like this: + + + + + + +束縛がデフォルトでイミュータブルであるのは複合的な理由によるものですが、Rustの主要な焦点、安全性の一環だと思うことが出来ます。 +もし `mut` を忘れたらコンパイラが捕捉して、変更するつもりでなかったものを変更した旨を教えてくれます。 +束縛がデフォルトでミュータブルだったらコンパイラはこれを捕捉できません。 +もし _本当に_ 変更を意図していたのなら話は簡単です。 `mut` をつけ加えればいいのです。 + + + + + +可能な時にミュータブルを避けた方が良い理由は他にもあるのですがそれはこのガイドの範囲を越えています。 +一般に、明示的な変更は避けれることが多いのでRustでもそうした方が良いのです。 +しかし変更が本当に必要なこともあるという意味でもあるので、厳禁という訳ではないのです。 + + +# 束縛を初期化する + + + + +Rustの束縛はもう1つ他の言語と異る点があります。束縛を使う前に値で初期化されている必要があるのです。 + + +試してみましょう。 `src/main.rs` をいじってこのようにしてみて下さい。 ```rust fn main() { @@ -153,8 +168,10 @@ fn main() { } ``` -You can use `cargo build` on the command line to build it. You’ll get a -warning, but it will still print "Hello, world!": + + +コマンドラインで `cargo build` を使ってビルド出来ます。 +ウォーニングが出ますが、それでもまだ「Hello, world!」は印字されます。 ```text Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world) @@ -164,9 +181,12 @@ src/main.rs:2 let x: i32; ^ ``` -Rust warns us that we never use the variable binding, but since we never use -it, no harm, no foul. Things change if we try to actually use this `x`, -however. Let’s do that. Change your program to look like this: + + + +Rustは一度も使われない変数について警告を出しますが、一度も使われないので人畜無害です。 +ところがこの `x` を使おうとすると事は一変ます。やってみましょう。 +プログラムをこのように変更して下さい。 ```rust,ignore fn main() { @@ -176,7 +196,8 @@ fn main() { } ``` -And try to build it. You’ll get an error: + +そしてビルドしてみて下さい。このようなエラーが出る筈です。 ```bash $ cargo build @@ -192,21 +213,31 @@ error: aborting due to previous error Could not compile `hello_world`. ``` -Rust will not let us use a value that has not been initialized. Next, let’s -talk about this stuff we've added to `println!`. - -If you include two curly braces (`{}`, some call them moustaches...) in your -string to print, Rust will interpret this as a request to interpolate some sort -of value. *String interpolation* is a computer science term that means "stick -in the middle of a string." We add a comma, and then `x`, to indicate that we -want `x` to be the value we’re interpolating. The comma is used to separate -arguments we pass to functions and macros, if you’re passing more than one. - -When you just use the curly braces, Rust will attempt to display the value in a -meaningful way by checking out its type. If you want to specify the format in a -more detailed manner, there are a [wide number of options available][format]. -For now, we'll just stick to the default: integers aren't very complicated to -print. + + +Rustでは未初期化の値を使うことは許されていません。 +次に、 `println!` に追加したものについて話しましょう。 + + + + + + + +印字する文字列に2つの波括弧(`{}`、口髭という人もいます…(訳注: 日本語だと「中括弧」と呼ぶ人もいますね))を入れました。 +Rustはこれを何かの値を入れて(interpolate、インターポーレート)くれという要求だと解します。 +*文字列インターポーレーション* (String interpolation)はコンピュータサイエンスの用語で、「文字列の中に差し込む」という意味です。 +その後に続けてカンマ、そして `x` を置いて `x` がインターポーレートしようとしている値だと指示しています。 +カンマは2つ以上の引数を関数やマクロに渡す時に使われます。 + + + + + + +単に波括弧だけを使った時は、Rustはインターポーレートされる値の型を調べて意味のある方法で表示しようとします。 +フォーマットをさらに詳しく指定したいなら[数多くのオプションが利用出来ます][format]。 +とりあえずのところ、デフォルトに従ましょう。整数の印字はそれほど複雑ではありません。 [format]: ../std/fmt/index.html From bb10b9c2bd89ec14a2feeaa40ff8f5f617496326 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Tue, 2 Feb 2016 22:27:17 +0900 Subject: [PATCH 05/12] add "type inference" to translation table --- TranslationTable.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TranslationTable.md b/TranslationTable.md index ef6fc4c6..812b6809 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -69,6 +69,7 @@ | system | システム | tick | クオート | trait | トレイト +| type inference | 型推論 | unsized type | サイズ不定型 | vector | ベクタ | wildcard | ワイルドカード From a474fdf40e1d4d33feae631a10f77324e9a22337 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Tue, 2 Feb 2016 23:47:31 +0900 Subject: [PATCH 06/12] complete translation --- 1.6/ja/book/variable-bindings.md | 78 ++++++++++++++++++++------------ TranslationTable.md | 17 +++++++ 2 files changed, 66 insertions(+), 29 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index e6c1c847..c8f7a39e 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -4,11 +4,11 @@ -事実上全ての「Hello World」でないRustのプログラムは *変数束縛*を使っています。 +事実上全ての「Hello World」でないRustのプログラムは *変数束縛* を使っています。 変数束縛は何らかの値を名前へと束縛するので、後でその値を使えます。 このように、 `let` が束縛を導入するのに使われています。 -> 訳注: 普通、束縛というときは名前を値へと束縛しますが、ドキュメントでは逆になっています。 +> 訳注: 普通、束縛というときは名前 *を* 値 *へ* と束縛しますが、このドキュメントでは逆になっています。 > Rustでは他の言語と違って1つの値に対して1つの名前が対応するのであえてこう書いてるのかもしれません。 ```rust @@ -145,7 +145,7 @@ x = 10; -可能な時にミュータブルを避けた方が良い理由は他にもあるのですがそれはこのガイドの範囲を越えています。 +可能な時はにミュータブルを避けた方が良い理由は他にもあるのですがそれはこのガイドの範囲を越えています。 一般に、明示的な変更は避けれることが多いのでRustでもそうした方が良いのです。 しかし変更が本当に必要なこともあるという意味でもあるので、厳禁という訳ではないのです。 @@ -241,14 +241,20 @@ Rustはこれを何かの値を入れて(interpolate、インターポーレー [format]: ../std/fmt/index.html -# Scope and shadowing + +# スコープとシャドイング + + + + + + + +束縛に話を戻しましょう。変数束縛にはスコープがあります。変数束縛は定義されたブロック内でしか生きていません。 +ブロックは `{` と `}` に囲まれた文の集りです。関数定義もブロックです! +以下の例では異なるブロックで生きる2つの変数束縛、 `x` と `y` を定義しています。 +`x` は `fn main() {}` ブロックの中でアクセス可能ですが、 `y` は内側のブロックからのみアクセス出来ます。 -Let’s get back to bindings. Variable bindings have a scope - they are -constrained to live in a block they were defined in. A block is a collection -of statements enclosed by `{` and `}`. Function definitions are also blocks! -In the following example we define two variable bindings, `x` and `y`, which -live in different blocks. `x` can be accessed from inside the `fn main() {}` -block, while `y` can be accessed only from inside the inner block: ```rust,ignore fn main() { @@ -257,20 +263,24 @@ fn main() { let y: i32 = 3; println!("The value of x is {} and value of y is {}", x, y); } - println!("The value of x is {} and value of y is {}", x, y); // This won't work +#// println!("The value of x is {} and value of y is {}", x, y); // This won't work + println!("The value of x is {} and value of y is {}", x, y); // これは動きません } ``` -The first `println!` would print "The value of x is 17 and the value of y is -3", but this example cannot be compiled successfully, because the second -`println!` cannot access the value of `y`, since it is not in scope anymore. -Instead we get this error: + + + + +最初の `println!` は「The value of x is 17 and the value of y is 3」(訳注: 「xの値は17でyの値は3」)と印字する筈ですが、 +2つめの `println!` は `y` がもうスコープにいないため `y` にアクセス出来ないのでこの例はコンパイル出来ません。 +代わりに以下のようなエラーが出ます。 ```bash $ cargo build Compiling hello v0.1.0 (file:///home/you/projects/hello_world) main.rs:7:62: 7:63 error: unresolved name `y`. Did you mean `x`? [E0425] -main.rs:7 println!("The value of x is {} and value of y is {}", x, y); // This won't work +main.rs:7 println!("The value of x is {} and value of y is {}", x, y); // これは動きません ^ note: in expansion of format_args! :2:25: 2:56 note: expansion site @@ -285,32 +295,42 @@ Could not compile `hello`. To learn more, run the command again with --verbose. ``` -Additionally, variable bindings can be shadowed. This means that a later -variable binding with the same name as another binding, that's currently in -scope, will override the previous binding. + + + +さらに加えて、変数束縛は覆い隠すことが出来ます(訳注: このことをシャドイングと言います)。 +つまり後に出てくる同じ名前の変数束縛があるとそれがスコープに入り、以前の束縛を上書きするのです。 ```rust let x: i32 = 8; { - println!("{}", x); // Prints "8" +#// println!("{}", x); // Prints "8" + println!("{}", x); // "8" を印字する let x = 12; - println!("{}", x); // Prints "12" +#// println!("{}", x); // Prints "12" + println!("{}", x); // "12" を印字する } -println!("{}", x); // Prints "8" +#// println!("{}", x); // Prints "8" +println!("{}", x); // "8"を印字する let x = 42; -println!("{}", x); // Prints "42" +#// println!("{}", x); // Prints "42" +println!("{}", x); // "42" を印字する ``` -Shadowing and mutable bindings may appear as two sides of the same coin, but -they are two distinct concepts that can't always be used interchangeably. For -one, shadowing enables us to rebind a name to a value of a different type. It -is also possible to change the mutability of a binding. + + + + +シャドイングとミュータブルな束縛はコインの表と裏のように見えるかもしれませんが、それぞれ独立な概念であり互いに代用が出来ないケースがあります。 +その1つにシャドイングは同じ名前に違う型の値を再束縛することが出来ます。 ```rust let mut x: i32 = 1; x = 7; -let x = x; // x is now immutable and is bound to 7 +#// let x = x; // x is now immutable and is bound to 7 +let x = x; // xはイミュータブルになって7に束縛されました let y = 4; -let y = "I can also be bound to text!"; // y is now of a different type +#// let y = "I can also be bound to text!"; // y is now of a different type +let y = "I can also be bound to text!"; // yは違う型になりました ``` diff --git a/TranslationTable.md b/TranslationTable.md index 812b6809..944c64b3 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -15,6 +15,7 @@ | application | アプリケーション | arity | アリティ | array | 配列 +| assignment | 代入 | associated - | 関連- | attribute | アトリビュート | binary | バイナリ @@ -24,6 +25,7 @@ | capture | キャプチャ | closure | クロージャ | coercion | 型強制 +| comma | カンマ | compiler | コンパイラ | constant | 定数 | crate | クレート @@ -43,6 +45,9 @@ | generics | ジェネリクス | identifier | 識別子 | immutable | イミュータブル +| initialize | 初期化する +| interpolate | インターポーレートする +| interpolation | インターポーレーション | Intrinsics | Intrinsic | Lang Items | Lang Item | library | ライブラリ @@ -54,14 +59,22 @@ | move | ムーブ | mutable | ミュータブル | mutability | ミュータビリティ +| mutable binding | ミュータブルな束縛 | owner | 所有者 | ownership | 所有権 | panic | パニック +| re-assignment | 再代入 +| rebind | 再束縛 | return | 返す +| scope | スコープ | shadow | 覆い隠す +| shadowing | シャドイング | signature | シグネチャ +| signed | 符号付き | slice | スライス | slicing | スライシング +| string | 文字列 +| string interpolation | 文字列インターポーレーション | struct | 構造体 | structure | ストラクチャ | symbol | シンボル @@ -70,6 +83,10 @@ | tick | クオート | trait | トレイト | type inference | 型推論 +| unsigned | 符号無し | unsized type | サイズ不定型 +| variable | 変数 +| variable binding | 変数束縛 | vector | ベクタ +| warning | ウォーニング | wildcard | ワイルドカード From 9a5e6a571cbf63b3efa1e17765f33fd247517ddc Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Wed, 3 Feb 2016 00:03:14 +0900 Subject: [PATCH 07/12] final tweak --- 1.6/ja/book/variable-bindings.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index c8f7a39e..07d12666 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -224,8 +224,8 @@ Rustでは未初期化の値を使うことは許されていません。 -印字する文字列に2つの波括弧(`{}`、口髭という人もいます…(訳注: 日本語だと「中括弧」と呼ぶ人もいますね))を入れました。 -Rustはこれを何かの値を入れて(interpolate、インターポーレート)くれという要求だと解します。 +印字する文字列に2つの波括弧(`{}`、口髭という人もいます…(訳注: 海外の顔文字は横になっているので首を傾けて `{` を眺めてみて下さい。また、日本語だと「中括弧」と呼ぶ人もいますね))を入れました。 +Rustはこれを何かの値を入れて(interpolate、インターポーレート)くれという要求だと解釈します。 *文字列インターポーレーション* (String interpolation)はコンピュータサイエンスの用語で、「文字列の中に差し込む」という意味です。 その後に続けてカンマ、そして `x` を置いて `x` がインターポーレートしようとしている値だと指示しています。 カンマは2つ以上の引数を関数やマクロに渡す時に使われます。 @@ -251,7 +251,7 @@ Rustはこれを何かの値を入れて(interpolate、インターポーレー 束縛に話を戻しましょう。変数束縛にはスコープがあります。変数束縛は定義されたブロック内でしか生きていません。 -ブロックは `{` と `}` に囲まれた文の集りです。関数定義もブロックです! +ブロックは `{` と `}` に囲まれた文の集まりです。関数定義もブロックです! 以下の例では異なるブロックで生きる2つの変数束縛、 `x` と `y` を定義しています。 `x` は `fn main() {}` ブロックの中でアクセス可能ですが、 `y` は内側のブロックからのみアクセス出来ます。 @@ -263,7 +263,7 @@ fn main() { let y: i32 = 3; println!("The value of x is {} and value of y is {}", x, y); } -#// println!("The value of x is {} and value of y is {}", x, y); // This won't work +# // println!("The value of x is {} and value of y is {}", x, y); // This won't work println!("The value of x is {} and value of y is {}", x, y); // これは動きません } ``` @@ -304,17 +304,17 @@ To learn more, run the command again with --verbose. ```rust let x: i32 = 8; { -#// println!("{}", x); // Prints "8" - println!("{}", x); // "8" を印字する +# // println!("{}", x); // Prints "8" + println!("{}", x); // "8"を印字する let x = 12; -#// println!("{}", x); // Prints "12" - println!("{}", x); // "12" を印字する +# // println!("{}", x); // Prints "12" + println!("{}", x); // "12"を印字する } -#// println!("{}", x); // Prints "8" +# // println!("{}", x); // Prints "8" println!("{}", x); // "8"を印字する let x = 42; -#// println!("{}", x); // Prints "42" -println!("{}", x); // "42" を印字する +# // println!("{}", x); // Prints "42" +println!("{}", x); // "42"を印字する ``` @@ -327,10 +327,10 @@ println!("{}", x); // "42" を印字する ```rust let mut x: i32 = 1; x = 7; -#// let x = x; // x is now immutable and is bound to 7 +# // let x = x; // x is now immutable and is bound to 7 let x = x; // xはイミュータブルになって7に束縛されました let y = 4; -#// let y = "I can also be bound to text!"; // y is now of a different type +# // let y = "I can also be bound to text!"; // y is now of a different type let y = "I can also be bound to text!"; // yは違う型になりました ``` From 8982b4c561d2ac206445b6d54124e71a4e660a70 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Wed, 3 Feb 2016 23:31:10 +0900 Subject: [PATCH 08/12] reflect review --- 1.6/ja/book/variable-bindings.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index 07d12666..09e79383 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -21,7 +21,7 @@ fn main() { 例で毎回 `fn main() {` と書くのは長ったらしいのでこれ以後は省略します。 -もし試しながら読んでいるのならそのまま書くのではなくちゃんと `main()` 関数の中身を編集するようにしてください、そうしないとエラーになります。 +もし試しながら読んでいるのならそのまま書くのではなくちゃんと `main()` 関数の中身を編集するようにしてください。そうしないとエラーになります。 # パターン @@ -81,7 +81,7 @@ Rustには多くのプリミティブな整数型があります。プリミテ -以後の例では型はコンメントで注釈することにします。 +以後の例では型はコメントで注釈することにします。 先の例はこのようになります。 ```rust @@ -118,7 +118,7 @@ error: re-assignment of immutable variable `x` > 訳注: > ``` -> エラー: イミュータブルな変数 `x` に最代入しています +> エラー: イミュータブルな変数 `x` に再代入しています > ``` @@ -136,7 +136,7 @@ x = 10; -束縛がデフォルトでイミュータブルであるのは複合的な理由によるものですが、Rustの主要な焦点、安全性の一環だと思うことが出来ます。 +束縛がデフォルトでイミュータブルであるのは複合的な理由によるものですが、Rustの主要な焦点、安全性の一環だと考えることが出来ます。 もし `mut` を忘れたらコンパイラが捕捉して、変更するつもりでなかったものを変更した旨を教えてくれます。 束縛がデフォルトでミュータブルだったらコンパイラはこれを捕捉できません。 もし _本当に_ 変更を意図していたのなら話は簡単です。 `mut` をつけ加えればいいのです。 @@ -146,8 +146,8 @@ x = 10; 可能な時はにミュータブルを避けた方が良い理由は他にもあるのですがそれはこのガイドの範囲を越えています。 -一般に、明示的な変更は避けれることが多いのでRustでもそうした方が良いのです。 -しかし変更が本当に必要なこともあるという意味でもあるので、厳禁という訳ではないのです。 +一般に、明示的な変更は避けられることが多いのでRustでもそうした方が良いのです。 +しかし変更が本当に必要なこともあるという意味で、厳禁という訳ではないのです。 # 束縛を初期化する @@ -185,7 +185,7 @@ src/main.rs:2 let x: i32; Rustは一度も使われない変数について警告を出しますが、一度も使われないので人畜無害です。 -ところがこの `x` を使おうとすると事は一変ます。やってみましょう。 +ところがこの `x` を使おうとすると事は一変します。やってみましょう。 プログラムをこのように変更して下さい。 ```rust,ignore @@ -252,7 +252,7 @@ Rustはこれを何かの値を入れて(interpolate、インターポーレー 束縛に話を戻しましょう。変数束縛にはスコープがあります。変数束縛は定義されたブロック内でしか生きていません。 ブロックは `{` と `}` に囲まれた文の集まりです。関数定義もブロックです! -以下の例では異なるブロックで生きる2つの変数束縛、 `x` と `y` を定義しています。 +以下の例では異なるブロックで有効な2つの変数束縛、 `x` と `y` を定義しています。 `x` は `fn main() {}` ブロックの中でアクセス可能ですが、 `y` は内側のブロックからのみアクセス出来ます。 From fd3ed10269f08d0d3f2739dd85dd6229721c6a17 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Wed, 3 Feb 2016 23:33:42 +0900 Subject: [PATCH 09/12] prepare for merge --- TranslationTable.md | 160 ++++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/TranslationTable.md b/TranslationTable.md index 944c64b3..7248adc2 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -10,83 +10,83 @@ | English | 日本語 |:----------------------|:------ -| alignment | アラインメント -| allocator | アロケータ -| application | アプリケーション -| arity | アリティ -| array | 配列 -| assignment | 代入 -| associated - | 関連- -| attribute | アトリビュート -| binary | バイナリ -| binding | 束縛 -| block | ブロック -| borrowing | 借用 -| capture | キャプチャ -| closure | クロージャ -| coercion | 型強制 -| comma | カンマ -| compiler | コンパイラ -| constant | 定数 -| crate | クレート -| declaration statement | 宣言文 -| dereferencing | 参照外し -| destructuring | 分配 -| directive | ディレクティブ -| distribution | 配布物 -| diverge | ダイバージ -| diverging | ダイバージング -| documentation comment | ドキュメンテーションコメント -| documentation test | ドキュメンテーションテスト -| early return | 早期リターン -| enum | 列挙型 -| expression statement | 式文 -| feature | フィーチャ -| generics | ジェネリクス -| identifier | 識別子 -| immutable | イミュータブル -| initialize | 初期化する -| interpolate | インターポーレートする -| interpolation | インターポーレーション -| Intrinsics | Intrinsic -| Lang Items | Lang Item -| library | ライブラリ -| lifetime | ライフタイム -| link | リンク -| lint | リント -| match | マッチ -| memory | メモリ -| move | ムーブ -| mutable | ミュータブル -| mutability | ミュータビリティ -| mutable binding | ミュータブルな束縛 -| owner | 所有者 -| ownership | 所有権 -| panic | パニック -| re-assignment | 再代入 -| rebind | 再束縛 -| return | 返す -| scope | スコープ -| shadow | 覆い隠す -| shadowing | シャドイング -| signature | シグネチャ -| signed | 符号付き -| slice | スライス -| slicing | スライシング -| string | 文字列 -| string interpolation | 文字列インターポーレーション -| struct | 構造体 -| structure | ストラクチャ -| symbol | シンボル -| syntactic sugar | 糖衣構文 -| system | システム -| tick | クオート -| trait | トレイト -| type inference | 型推論 -| unsigned | 符号無し -| unsized type | サイズ不定型 -| variable | 変数 -| variable binding | 変数束縛 -| vector | ベクタ -| warning | ウォーニング -| wildcard | ワイルドカード +| alignment | アラインメント +| allocator | アロケータ +| application | アプリケーション +| arity | アリティ +| array | 配列 +| assignment | 代入 +| associated - | 関連- +| attribute | アトリビュート +| binary | バイナリ +| binding | 束縛 +| block | ブロック +| borrowing | 借用 +| capture | キャプチャ +| closure | クロージャ +| coercion | 型強制 +| comma | カンマ +| compiler | コンパイラ +| constant | 定数 +| crate | クレート +| declaration statement | 宣言文 +| dereferencing | 参照外し +| destructuring | 分配 +| directive | ディレクティブ +| distribution | 配布物 +| diverge | ダイバージ +| diverging | ダイバージング +| documentation comment | ドキュメンテーションコメント +| documentation test | ドキュメンテーションテスト +| early return | 早期リターン +| enum | 列挙型 +| expression statement | 式文 +| feature | フィーチャ +| generics | ジェネリクス +| identifier | 識別子 +| immutable | イミュータブル +| initialize | 初期化する +| interpolate | インターポーレートする +| interpolation | インターポーレーション +| Intrinsics | Intrinsic +| Lang Items | Lang Item +| library | ライブラリ +| lifetime | ライフタイム +| link | リンク +| lint | リント +| match | マッチ +| memory | メモリ +| move | ムーブ +| mutable | ミュータブル +| mutability | ミュータビリティ +| mutable binding | ミュータブルな束縛 +| owner | 所有者 +| ownership | 所有権 +| panic | パニック +| re-assignment | 再代入 +| rebind | 再束縛 +| return | 返す +| scope | スコープ +| shadow | 覆い隠す +| shadowing | シャドイング +| signature | シグネチャ +| signed | 符号付き +| slice | スライス +| slicing | スライシング +| string | 文字列 +| string interpolation | 文字列インターポーレーション +| struct | 構造体 +| structure | ストラクチャ +| symbol | シンボル +| syntactic sugar | 糖衣構文 +| system | システム +| tick | クオート +| trait | トレイト +| type inference | 型推論 +| unsigned | 符号無し +| unsized type | サイズ不定型 +| variable | 変数 +| variable binding | 変数束縛 +| vector | ベクタ +| warning | ウォーニング +| wildcard | ワイルドカード From 0dd2f7dcb2fe562165a2ba4b91bfe7a25511c05f Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Thu, 4 Feb 2016 10:05:38 +0900 Subject: [PATCH 10/12] fix another 'live' --- 1.6/ja/book/variable-bindings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index 09e79383..33c6abf7 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -250,7 +250,7 @@ Rustはこれを何かの値を入れて(interpolate、インターポーレー -束縛に話を戻しましょう。変数束縛にはスコープがあります。変数束縛は定義されたブロック内でしか生きていません。 +束縛に話を戻しましょう。変数束縛にはスコープがあります。変数束縛は定義されたブロック内でしか有効でありません。 ブロックは `{` と `}` に囲まれた文の集まりです。関数定義もブロックです! 以下の例では異なるブロックで有効な2つの変数束縛、 `x` と `y` を定義しています。 `x` は `fn main() {}` ブロックの中でアクセス可能ですが、 `y` は内側のブロックからのみアクセス出来ます。 From 4a9f9ad573621b55f852084f8fe6a144ebd62cbc Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Sun, 7 Feb 2016 15:44:30 +0900 Subject: [PATCH 11/12] fixes respecting review --- 1.6/ja/book/variable-bindings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index 33c6abf7..491631f2 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -77,7 +77,7 @@ let x: i32 = 5; この場合 `x` を32bit符号付き整数として表現することを選びました。 Rustには多くのプリミティブな整数型があります。プリミティブな整数型は符号付き型は `i` 、符号無し型は `u` から始まります。 -整数型として可能なサイズは8、16、32、64です。 +整数型として可能なサイズは8、16、32、64ビットです。 @@ -171,7 +171,7 @@ fn main() { コマンドラインで `cargo build` を使ってビルド出来ます。 -ウォーニングが出ますが、それでもまだ「Hello, world!」は印字されます。 +警告が出ますが、それでもまだ「Hello, world!」は印字されます。 ```text Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world) From 65489ee1b499bb9acd8d6b2f56440682ce588d62 Mon Sep 17 00:00:00 2001 From: "Sunrin SHIMURA (keen)" <3han5chou7@gmail.com> Date: Sun, 7 Feb 2016 15:47:00 +0900 Subject: [PATCH 12/12] =?UTF-8?q?s/=E3=82=B7=E3=83=A3=E3=83=89=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=B0/=E3=82=B7=E3=83=A3=E3=83=89=E3=83=BC?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B0/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1.6/ja/book/guessing-game.md | 4 ++-- 1.6/ja/book/variable-bindings.md | 8 ++++---- TranslationTable.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/1.6/ja/book/guessing-game.md b/1.6/ja/book/guessing-game.md index 50147480..7c52e2ce 100644 --- a/1.6/ja/book/guessing-game.md +++ b/1.6/ja/book/guessing-game.md @@ -917,9 +917,9 @@ fn main() { ちょっと待って下さい、既に`guess`を定義してありますよね? -してあります、が、Rustでは以前の`guess`の定義を新しいもので「隠す」ことが出来ます(訳注: このように隠すことをシャドイングといいます)。 +してあります、が、Rustでは以前の`guess`の定義を新しいもので「隠す」ことが出来ます(訳注: このように隠すことをシャドーイングといいます)。 まさにこのように、最初`String`であった`guess`を`u32`に変換したい、というような状況でよく使われます。 -シャドイングのおかげで`guess_str`と`guess`のように別々の名前を考える必要はなくなり、`guess`の名前を再利用出来ます。 +シャドーイングのおかげで`guess_str`と`guess`のように別々の名前を考える必要はなくなり、`guess`の名前を再利用出来ます。 `guess`を先に書いたような値に束縛します。 diff --git a/1.6/ja/book/variable-bindings.md b/1.6/ja/book/variable-bindings.md index 491631f2..832bc059 100644 --- a/1.6/ja/book/variable-bindings.md +++ b/1.6/ja/book/variable-bindings.md @@ -242,7 +242,7 @@ Rustはこれを何かの値を入れて(interpolate、インターポーレー [format]: ../std/fmt/index.html -# スコープとシャドイング +# スコープとシャドーイング @@ -298,7 +298,7 @@ To learn more, run the command again with --verbose. -さらに加えて、変数束縛は覆い隠すことが出来ます(訳注: このことをシャドイングと言います)。 +さらに加えて、変数束縛は覆い隠すことが出来ます(訳注: このことをシャドーイングと言います)。 つまり後に出てくる同じ名前の変数束縛があるとそれがスコープに入り、以前の束縛を上書きするのです。 ```rust @@ -321,8 +321,8 @@ println!("{}", x); // "42"を印字する -シャドイングとミュータブルな束縛はコインの表と裏のように見えるかもしれませんが、それぞれ独立な概念であり互いに代用が出来ないケースがあります。 -その1つにシャドイングは同じ名前に違う型の値を再束縛することが出来ます。 +シャドーイングとミュータブルな束縛はコインの表と裏のように見えるかもしれませんが、それぞれ独立な概念であり互いに代用が出来ないケースがあります。 +その1つにシャドーイングは同じ名前に違う型の値を再束縛することが出来ます。 ```rust let mut x: i32 = 1; diff --git a/TranslationTable.md b/TranslationTable.md index 7f040f00..9dd8008f 100644 --- a/TranslationTable.md +++ b/TranslationTable.md @@ -76,7 +76,7 @@ | return | 返す | scope | スコープ | shadow | 覆い隠す -| shadowing | シャドイング +| shadowing | シャドーイング | signature | シグネチャ | signed | 符号付き | slice | スライス