@@ -175,7 +175,7 @@ <h1><a class="header" href="#数当てゲームをプログラムする" id="数
175
175
program will indicate whether the guess is too low or too high. If the guess is
176
176
correct, the game will print a congratulatory message and exit.
177
177
-->
178
- < p > 古典的な初心者向けのプログラミング問題を実装してみましょう: 数当てゲームです。
178
+ < p > 古典的な初心者向けのプログラミング問題を実装してみましょう: 数当てゲームです。
179
179
これは以下のように動作します: プログラムは1から100までの乱数整数を生成します。
180
180
そしてプレーヤーに予想を入力するよう促します。予想を入力したら、プログラムは、
181
181
その予想が小さすぎたか大きすぎたかを出力します。予想が当たっていれば、ゲームは祝福メッセージを表示し、
@@ -320,7 +320,7 @@ <h2><a class="header" href="#予想を処理する" id="予想を処理する">
320
320
statement. Using the `std::io` library provides you with a number of useful
321
321
features, including the ability to accept user input.
322
322
-->
323
- < p > デフォルトでは、< a href ="../.. /std/prelude/index.html "> < em > prelude</ em > </ a > <!-- ignored --> に存在するいくつかの型のみ使えます。
323
+ < p > デフォルトでは、< a href ="https://doc.rust-lang.org /std/prelude/index.html "> < em > prelude</ em > </ a > <!-- ignored --> に存在するいくつかの型のみ使えます。
324
324
もし、使用したい型がpreludeにない場合は、< code > use</ code > 文で明示的にその型をスコープに導入する必要があります。
325
325
< code > std::io</ code > ライブラリを使用することで、ユーザ入力を受け付ける能力などの実用的な機能の多くを使用することができます。</ p >
326
326
<!--
@@ -404,7 +404,7 @@ <h3><a class="header" href="#値を変数に保持する" id="値を変数に保
404
404
< p > 数当てゲームのプログラムに戻りましょう。さあ、< code > let mut guess</ code > が< code > guess</ code > という名前の可変変数を導入するとわかりましたね。
405
405
イコール記号(< code > =</ code > )の反対側には、変数< code > guess</ code > が束縛される値があります。この値は、
406
406
< code > String::new</ code > 関数の呼び出し結果であり、この関数は、< code > String</ code > 型のオブジェクトを返します。
407
- < a href ="../.. /std/string/struct.String.html "> < code > String</ code > </ a > <!-- ignore --> 型は、標準ライブラリによって提供される文字列型で、
407
+ < a href ="https://doc.rust-lang.org /std/string/struct.String.html "> < code > String</ code > </ a > <!-- ignore --> 型は、標準ライブラリによって提供される文字列型で、
408
408
サイズ可変、UTF-8エンコードされたテキスト破片になります。</ p >
409
409
<!--
410
410
The `::` syntax in the `::new` line indicates that `new` is an *associated
@@ -445,15 +445,15 @@ <h3><a class="header" href="#値を変数に保持する" id="値を変数に保
445
445
type that represents a handle to the standard input for your terminal.
446
446
-->
447
447
< p > 仮に、プログラムの冒頭で< code > use std::io</ code > としていなければ、この関数呼び出しは、< code > std::io::stdin</ code > と記述していたでしょう。
448
- この< code > stdin</ code > 関数は、 < a href ="../.. /std/io/struct.Stdin.html "> < code > std::io::Stdin</ code > </ a > <!-- ignore --> オブジェクトを返し、この型は、
448
+ この< code > stdin</ code > 関数は、 < a href ="https://doc.rust-lang.org /std/io/struct.Stdin.html "> < code > std::io::Stdin</ code > </ a > <!-- ignore --> オブジェクトを返し、この型は、
449
449
ターミナルの標準入力へのハンドルを表す型になります。</ p >
450
450
<!--
451
451
The next part of the code, `.read_line(&mut guess)`, calls the
452
452
[`read_line`][read_line] method on the standard input handle to
453
453
get input from the user. We’re also passing one argument to `read_line`: `&mut
454
454
guess`.
455
455
-->
456
- < p > その次のコード片、< code > .read_line(&mut guess)</ code > は、標準入力ハンドルの< a href ="../.. /std/io/struct.Stdin.html#method.read_line "> < code > read_line</ code > </ a > <!-- ignore -->
456
+ < p > その次のコード片、< code > .read_line(&mut guess)</ code > は、標準入力ハンドルの< a href ="https://doc.rust-lang.org /std/io/struct.Stdin.html#method.read_line "> < code > read_line</ code > </ a > <!-- ignore -->
457
457
メソッドを呼び出して、ユーザから入力を受け付けます。また、< code > read_line</ code > メソッドに対して、< code > &mut guess</ code > という引数を一つ渡していますね。</ p >
458
458
<!--
459
459
The job of `read_line` is to take whatever the user types into standard input
@@ -518,8 +518,8 @@ <h3><a class="header" href="#result型で失敗の可能性を扱う" id="result
518
518
well as specific versions for submodules, such as `io::Result`.
519
519
-->
520
520
< p > 以前にも述べたように、< code > read_line</ code > メソッドは、渡された文字列にユーザが入力したものを入れ込むだけでなく、
521
- 値も返します(今回は< a href ="../.. /std/io/type.Result.html "> < code > io::Result</ code > </ a > <!-- ignore --> です)。 Rustには< code > Result</ code > と名のついた型が、
522
- 標準ライブラリにたくさんあります: 汎用の< a href ="../.. /std/result/enum.Result.html "> < code > Result</ code > </ a > <!-- ignore --> の他、
521
+ 値も返します(今回は< a href ="https://doc.rust-lang.org /std/io/type.Result.html "> < code > io::Result</ code > </ a > <!-- ignore --> です)。 Rustには< code > Result</ code > と名のついた型が、
522
+ 標準ライブラリにたくさんあります: 汎用の< a href ="https://doc.rust-lang.org /std/result/enum.Result.html "> < code > Result</ code > </ a > <!-- ignore --> の他、
523
523
< code > io::Result</ code > などのサブモジュール用に特化したものまで。</ p >
524
524
<!--
525
525
The `Result` types are [*enumerations*][enums], often referred
@@ -553,7 +553,7 @@ <h3><a class="header" href="#result型で失敗の可能性を扱う" id="result
553
553
entered into standard input.
554
554
-->
555
555
< p > これら< code > Result</ code > 型の目的は、エラー処理の情報をコード化することです。< code > Result</ code > 型の値も、他の型同様、
556
- メソッドが定義されています。< code > io::Result</ code > オブジェクトには、呼び出し可能な< a href ="../.. /std/result/enum.Result.html#method.expect "> < code > expect</ code > メソッド</ a > <!-- ignore --> があります。
556
+ メソッドが定義されています。< code > io::Result</ code > オブジェクトには、呼び出し可能な< a href ="https://doc.rust-lang.org /std/result/enum.Result.html#method.expect "> < code > expect</ code > メソッド</ a > <!-- ignore --> があります。
557
557
この< code > io::Result</ code > オブジェクトが< code > Err</ code > 値の場合、< code > expect</ code > メソッドはプログラムをクラッシュさせ、
558
558
引数として渡されたメッセージを表示します。< code > read_line</ code > メソッドが< code > Err</ code > を返したら、
559
559
恐らく根底にあるOSによるエラーに起因するのでしょう。
@@ -721,7 +721,7 @@ <h3><a class="header" href="#クレートを使用して機能を追加する" i
721
721
Compiling libc v0.2.14 (libc v0.2.14をコンパイルしています)
722
722
Compiling rand v0.3.14 (rand v0.3.14をコンパイルしています)
723
723
Compiling guessing_game v0.1.0 (file:///projects/guessing_game) (guessing_game v0.1.0をコンパイルしています)
724
- Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs
724
+ Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs
725
725
</ code > </ pre >
726
726
<!--
727
727
<span class="caption">Listing 2-2: The output from running `cargo build` after
@@ -1070,7 +1070,7 @@ <h2><a class="header" href="#予想と秘密の数字を比較する" id="予想
1070
1070
< p > それから、一番下に新しく5行追加して< code > Ordering</ code > 型を使用しています。< code > cmp</ code > メソッドは、
1071
1071
2値を比較し、比較できるものに対してなら何に対しても呼び出せます。このメソッドは、
1072
1072
比較したいものへの参照を取ります: ここでは、< code > guess</ code > 変数と< code > secret_number</ code > 変数を比較しています。
1073
- それからこのメソッドは< code > use</ code > 文でスコープに導入した< code > Ordering</ code > 列挙型の値を返します。
1073
+ それからこのメソッドは< code > use</ code > 文でスコープに導入した< code > Ordering</ code > 列挙型の値を返します。
1074
1074
< a href ="ch06-02-match.html "> < code > match</ code > </ a > <!-- ignore --> 式を使用して、< code > guess</ code > 変数と< code > secret_number</ code > を< code > cmp</ code > に渡して返ってきた< code > Ordering</ code > の列挙子に基づき、
1075
1075
次の動作を決定しています。</ p >
1076
1076
<!--
@@ -1233,7 +1233,7 @@ <h2><a class="header" href="#予想と秘密の数字を比較する" id="予想
1233
1233
will infer that `secret_number` should be a `u32` as well. So now the
1234
1234
comparison will be between two values of the same type!
1235
1235
-->
1236
- < p > < a href ="../.. /std/primitive.str.html#method.parse "> 文字列の< code > parse</ code > メソッド</ a > <!-- ignore --> は、文字列を解析して何らかの数値にします。
1236
+ < p > < a href ="https://doc.rust-lang.org /std/primitive.str.html#method.parse "> 文字列の< code > parse</ code > メソッド</ a > <!-- ignore --> は、文字列を解析して何らかの数値にします。
1237
1237
このメソッドは、いろんな数値型を解析できるので、< code > let guess: u32</ code > としてコンパイラに私たちが求めている型をズバリ示唆する必要があるのです。
1238
1238
< code > guess</ code > の後のコロン(< code > :</ code > )がコンパイラに変数の型を注釈する合図になります。
1239
1239
Rustには、組み込みの数値型がいくつかあります; ここの< code > u32</ code > 型は、32ビットの非負整数です。
0 commit comments