@@ -1568,7 +1568,7 @@ enum CliError {
1568
1568
<!-- occurring: an error dealing with I/O or an error converting a string to a -->
1569
1569
<!-- number. The error could represent as many error types as you want by adding new -->
1570
1570
<!-- variants to the `enum` definition. -->
1571
- このエラー型は2種類のエラー、つまり、IOを扱っているときのエラー、または、文字列を通知に変換するときのエラーが起こる可能性を示しています 。
1571
+ このエラー型は2種類のエラー、つまり、IOを扱っているときのエラー、または、文字列を数値に変換するときのエラーが起こる可能性を示しています 。
1572
1572
` enum ` 定義のヴァリアントを増やせば、エラーの種類をいくらでも表現できます。
1573
1573
1574
1574
<!-- Implementing `Error` is pretty straight-forward. It's mostly going to be a lot -->
@@ -2139,7 +2139,7 @@ cargo build --release
2139
2139
Getoptsについては、あまり深く説明しませんが、詳細を解説した [ ドキュメント] [ 15 ] があります。
2140
2140
簡単に言うと、Getoptsはオプションのベクタから、引数のパーサーとヘルプメッセージを生成します(実際には、ベクタは構造体とメソッドの背後に隠れています)。
2141
2141
パースが終わると、プログラムの引数をRustの構造体へとデコードできます。
2142
- これにより 、例えば、フラグが指定されたかとか、フラグの引数がなんであったかといった、フラグの情報を取り出せるようになります。
2142
+ そこから 、例えば、フラグが指定されたかとか、フラグの引数がなんであったかといった、フラグの情報を取り出せるようになります。
2143
2143
プログラムに適切な ` extern crate ` 文を追加して、Getoptsの基本的な引数を設定すると、こうなります:
2144
2144
2145
2145
``` rust,ignore
@@ -2171,7 +2171,8 @@ fn main() {
2171
2171
let data_path = args[1].clone();
2172
2172
let city = args[2].clone();
2173
2173
2174
- // Do stuff with information
2174
+ # // Do stuff with information
2175
+ // 情報を元にいろいろなことをする
2175
2176
}
2176
2177
```
2177
2178
@@ -2460,7 +2461,8 @@ fn search<P: AsRef<Path>>
2460
2461
for row in rdr.decode::<Row>() {
2461
2462
let row = try!(row);
2462
2463
match row.population {
2463
- None => { } // skip it
2464
+ # // None => { } // skip it
2465
+ None => { } // スキップする
2464
2466
Some(count) => if row.city == city {
2465
2467
found.push(PopulationCount {
2466
2468
city: row.city,
@@ -2497,7 +2499,7 @@ fn search<P: AsRef<Path>>
2497
2499
このコードで1点注意があります:
2498
2500
` Box<Error> ` の代わりに ` Box<Error + Send + Sync> ` を使いました。
2499
2501
こうすると、プレーンな文字列をエラー型に変換できます。
2500
- [ この ` From ` 実装] ( ../std/convert/trait.From.html ) を使うために、このような追加の境界が必要でした 。
2502
+ [ この ` From ` 実装] ( ../std/convert/trait.From.html ) を使うために、このような追加の制限が必要でした 。
2501
2503
2502
2504
``` rust,ignore
2503
2505
# // 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>>
2636
2638
Some(ref file_path) => Box::new(try!(fs::File::open(file_path))),
2637
2639
};
2638
2640
let mut rdr = csv::Reader::from_reader(input);
2639
- // The rest remains unchanged!
2641
+ # // The rest remains unchanged!
2642
+ // これ以降は変更なし!
2640
2643
}
2641
2644
```
2642
2645
@@ -2740,7 +2743,8 @@ fn search<P: AsRef<Path>>
2740
2743
for row in rdr.decode::<Row>() {
2741
2744
let row = try!(row);
2742
2745
match row.population {
2743
- None => { } // skip it
2746
+ # // None => { } // skip it
2747
+ None => { } // スキップする
2744
2748
Some(count) => if row.city == city {
2745
2749
found.push(PopulationCount {
2746
2750
city: row.city,
@@ -2775,7 +2779,7 @@ fn search<P: AsRef<Path>>
2775
2779
<!-- 1. Defined a new error type. -->
2776
2780
<!-- 2. Added impls for `Error`, `Display` and two for `From`. -->
2777
2781
1 . 新しいエラー型を定義した。
2778
- 2 . ` Error ` と ` Display ` の実装を追加し、2つのエラー対して ` From ` も実装した。
2782
+ 2 . ` Error ` と ` Display ` の実装を追加し、2つのエラーに対して ` From ` も実装した。
2779
2783
2780
2784
<!-- The big downside here is that our program didn't improve a whole lot. -->
2781
2785
<!-- There is quite a bit of overhead to representing errors with `enum`s, -->
0 commit comments