Skip to content

Commit 7cf0585

Browse files
committed
error-handling - apply review comments (rust-lang-ja#101)
1 parent 4abcc69 commit 7cf0585

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

1.6/ja/book/error-handling.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ enum CliError {
15681568
<!-- occurring: an error dealing with I/O or an error converting a string to a -->
15691569
<!-- number. The error could represent as many error types as you want by adding new -->
15701570
<!-- variants to the `enum` definition. -->
1571-
このエラー型は2種類のエラー、つまり、IOを扱っているときのエラー、または、文字列を通知に変換するときのエラーが起こる可能性を示しています
1571+
このエラー型は2種類のエラー、つまり、IOを扱っているときのエラー、または、文字列を数値に変換するときのエラーが起こる可能性を示しています
15721572
`enum` 定義のヴァリアントを増やせば、エラーの種類をいくらでも表現できます。
15731573

15741574
<!-- Implementing `Error` is pretty straight-forward. It's mostly going to be a lot -->
@@ -2139,7 +2139,7 @@ cargo build --release
21392139
Getoptsについては、あまり深く説明しませんが、詳細を解説した [ドキュメント][15] があります。
21402140
簡単に言うと、Getoptsはオプションのベクタから、引数のパーサーとヘルプメッセージを生成します(実際には、ベクタは構造体とメソッドの背後に隠れています)。
21412141
パースが終わると、プログラムの引数をRustの構造体へとデコードできます。
2142-
これにより、例えば、フラグが指定されたかとか、フラグの引数がなんであったかといった、フラグの情報を取り出せるようになります。
2142+
そこから、例えば、フラグが指定されたかとか、フラグの引数がなんであったかといった、フラグの情報を取り出せるようになります。
21432143
プログラムに適切な `extern crate` 文を追加して、Getoptsの基本的な引数を設定すると、こうなります:
21442144

21452145
```rust,ignore
@@ -2171,7 +2171,8 @@ fn main() {
21712171
let data_path = args[1].clone();
21722172
let city = args[2].clone();
21732173
2174-
// Do stuff with information
2174+
# // Do stuff with information
2175+
// 情報を元にいろいろなことをする
21752176
}
21762177
```
21772178

@@ -2460,7 +2461,8 @@ fn search<P: AsRef<Path>>
24602461
for row in rdr.decode::<Row>() {
24612462
let row = try!(row);
24622463
match row.population {
2463-
None => { } // skip it
2464+
# // None => { } // skip it
2465+
None => { } // スキップする
24642466
Some(count) => if row.city == city {
24652467
found.push(PopulationCount {
24662468
city: row.city,
@@ -2497,7 +2499,7 @@ fn search<P: AsRef<Path>>
24972499
このコードで1点注意があります:
24982500
`Box<Error>` の代わりに `Box<Error + Send + Sync>` を使いました。
24992501
こうすると、プレーンな文字列をエラー型に変換できます。
2500-
[この `From` 実装](../std/convert/trait.From.html) を使うために、このような追加の境界が必要でした
2502+
[この `From` 実装](../std/convert/trait.From.html) を使うために、このような追加の制限が必要でした
25012503

25022504
```rust,ignore
25032505
# // We are making use of this impl in the code above, since we call `From::from`
@@ -2636,7 +2638,8 @@ fn search<P: AsRef<Path>>
26362638
Some(ref file_path) => Box::new(try!(fs::File::open(file_path))),
26372639
};
26382640
let mut rdr = csv::Reader::from_reader(input);
2639-
// The rest remains unchanged!
2641+
# // The rest remains unchanged!
2642+
// これ以降は変更なし!
26402643
}
26412644
```
26422645

@@ -2740,7 +2743,8 @@ fn search<P: AsRef<Path>>
27402743
for row in rdr.decode::<Row>() {
27412744
let row = try!(row);
27422745
match row.population {
2743-
None => { } // skip it
2746+
# // None => { } // skip it
2747+
None => { } // スキップする
27442748
Some(count) => if row.city == city {
27452749
found.push(PopulationCount {
27462750
city: row.city,
@@ -2775,7 +2779,7 @@ fn search<P: AsRef<Path>>
27752779
<!-- 1. Defined a new error type. -->
27762780
<!-- 2. Added impls for `Error`, `Display` and two for `From`. -->
27772781
1. 新しいエラー型を定義した。
2778-
2. `Error``Display` の実装を追加し、2つのエラー対して `From` も実装した。
2782+
2. `Error``Display` の実装を追加し、2つのエラーに対して `From` も実装した。
27792783

27802784
<!-- The big downside here is that our program didn't improve a whole lot. -->
27812785
<!-- There is quite a bit of overhead to representing errors with `enum`s, -->

0 commit comments

Comments
 (0)