Skip to content

Commit 0f629e7

Browse files
committed
ch09 エラー処理の和訳を最新版に更新
rust-lang/book@19c40bf
1 parent d2d9bbb commit 0f629e7

File tree

55 files changed

+1138
-1040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1138
-1040
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "panic"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

listings/ch09-error-handling/listing-09-01/output.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ $ cargo run
22
Compiling panic v0.1.0 (file:///projects/panic)
33
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
44
Running `target/debug/panic`
5-
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/slice/mod.rs:2806:10
6-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
5+
thread 'main' panicked at src/main.rs:4:6:
6+
index out of bounds: the len is 3 but the index is 99
7+
('main'スレッドはsrc/main.rs:4:6でパニックしました:
8+
境界外番号: 長さは3なのに、添え字は99です)
9+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "error-handling"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fs::File;
22

33
fn main() {
4-
let f = File::open("hello.txt");
4+
let greeting_file_result = File::open("hello.txt");
55
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "error-handling"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

listings/ch09-error-handling/listing-09-04/output.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@ $ cargo run
22
Compiling error-handling v0.1.0 (file:///projects/error-handling)
33
Finished dev [unoptimized + debuginfo] target(s) in 0.73s
44
Running `target/debug/error-handling`
5-
thread 'main' panicked at 'Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:8:23
6-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
5+
thread 'main' panicked at src/main.rs:8:23:
6+
Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }
7+
('main'スレッドは、src/main.rs:8:23でパニックしました:
8+
ファイルを開く際に問題がありました: Os { code: 2, kind: NotFound, message: "そのようなファイルやディレクトリはありません" })
9+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use std::fs::File;
22

33
fn main() {
4-
let f = File::open("hello.txt");
4+
let greeting_file_result = File::open("hello.txt");
55

6-
let f = match f {
6+
let greeting_file = match greeting_file_result {
77
Ok(file) => file,
8+
// "ファイルを開くのに問題がありました: {:?}"
89
Err(error) => panic!("Problem opening the file: {:?}", error),
910
};
1011
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "error-handling"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

listings/ch09-error-handling/listing-09-05/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ use std::fs::File;
22
use std::io::ErrorKind;
33

44
fn main() {
5-
let f = File::open("hello.txt");
5+
let greeting_file_result = File::open("hello.txt");
66

7-
let f = match f {
7+
let greeting_file = match greeting_file_result {
88
Ok(file) => file,
99
Err(error) => match error.kind() {
1010
ErrorKind::NotFound => match File::create("hello.txt") {
1111
Ok(fc) => fc,
12+
// "ファイルを作成するのに問題がありました: {:?}"
1213
Err(e) => panic!("Problem creating the file: {:?}", e),
1314
},
1415
other_error => {
15-
panic!("Problem opening the file: {:?}", other_error)
16+
// "ファイルを開くのに問題がありました: {:?}"
17+
panic!("Problem opening the file: {:?}", other_error);
1618
}
1719
},
1820
};
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "error-handling"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

0 commit comments

Comments
 (0)