Skip to content

Commit 6527b36

Browse files
committed
翻訳をアップデート。その結果として Fixes: #37
1 parent 70ce370 commit 6527b36

File tree

10 files changed

+113
-256
lines changed

10 files changed

+113
-256
lines changed

listings/ch10-generic-types-traits-and-lifetimes/listing-10-17/output.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
$ cargo run
22
Compiling chapter10 v0.1.0 (file:///projects/chapter10)
33
error[E0597]: `x` does not live long enough
4+
(エラー[E0597]: `x`の生存期間が短すぎます)
45
--> src/main.rs:7:17
56
|
67
7 | r = &x;
78
| ^^ borrowed value does not live long enough
9+
| (借用された値の生存期間が短すぎます)
810
8 | }
911
| - `x` dropped here while still borrowed
12+
| (`x`は借用されている間にここでドロップされました)
1013
9 |
1114
10 | println!("r: {}", r);
1215
| - borrow later used here
16+
| (その後、借用はここで使われています)
1317

1418
error: aborting due to previous error
1519

listings/ch10-generic-types-traits-and-lifetimes/listing-10-20/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ fn main() {
33
let string2 = "xyz";
44

55
let result = longest(string1.as_str(), string2);
6+
// 最長の文字列は、{}です
67
println!("The longest string is {}", result);
78
}

listings/ch10-generic-types-traits-and-lifetimes/listing-10-21/output.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
$ cargo run
22
Compiling chapter10 v0.1.0 (file:///projects/chapter10)
33
error[E0106]: missing lifetime specifier
4+
(エラー[E0106]: ライフタイム指定子が不足しています)
45
--> src/main.rs:9:33
56
|
67
9 | fn longest(x: &str, y: &str) -> &str {
78
| ^ expected lifetime parameter
9+
| (ライフタイム引数があるべきです)
810
|
911
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `x` or `y`
12+
(助言: この関数の戻り値型は借用された値を含んでいますが、
13+
シグニチャは、それが`x`と`y`どちらから借用されたものなのか宣言していません)
1014

1115
error: aborting due to previous error
1216

listings/ch10-generic-types-traits-and-lifetimes/listing-10-23/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// ANCHOR: here
22
fn main() {
3+
// 長い文字列は長い
34
let string1 = String::from("long string is long");
45

56
{
67
let string2 = String::from("xyz");
78
let result = longest(string1.as_str(), string2.as_str());
9+
// 一番長い文字列は{}
810
println!("The longest string is {}", result);
911
}
1012
}

listings/ch10-generic-types-traits-and-lifetimes/listing-10-25/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ struct ImportantExcerpt<'a> {
33
}
44

55
fn main() {
6+
// 僕をイシュマエルとお呼び。何年か前・・・
67
let novel = String::from("Call me Ishmael. Some years ago...");
8+
// "'.'が見つかりませんでした"
79
let first_sentence = novel.split('.').next().expect("Could not find a '.'");
810
let i = ImportantExcerpt {
911
part: first_sentence,

listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/output.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
$ cargo run
22
Compiling chapter10 v0.1.0 (file:///projects/chapter10)
33
error[E0515]: cannot return value referencing local variable `result`
4+
(エラー[E0515]: ローカル変数`result`を参照している値は返せません)
45
--> src/main.rs:11:5
56
|
67
11 | result.as_str()
78
| ------^^^^^^^^^
89
| |
910
| returns a value referencing data owned by the current function
1011
| `result` is borrowed here
12+
| (現在の関数に所有されているデータを参照する値を返しています
13+
| `result`はここで借用されています)
1114

1215
error: aborting due to previous error
1316

listings/ch10-generic-types-traits-and-lifetimes/no-listing-09-unrelated-lifetime/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn main() {
88

99
// ANCHOR: here
1010
fn longest<'a>(x: &str, y: &str) -> &'a str {
11+
// 本当に長い文字列
1112
let result = String::from("really long string");
1213
result.as_str()
1314
}

listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ impl<'a> ImportantExcerpt<'a> {
1313
// ANCHOR: 3rd
1414
impl<'a> ImportantExcerpt<'a> {
1515
fn announce_and_return_part(&self, announcement: &str) -> &str {
16+
// "お知らせします: {}"
1617
println!("Attention please: {}", announcement);
1718
self.part
1819
}

listings/ch10-generic-types-traits-and-lifetimes/no-listing-11-generics-traits-and-lifetimes/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fn longest_with_an_announcement<'a, T>(
2121
where
2222
T: Display,
2323
{
24+
// "アナウンス! {}"
2425
println!("Announcement! {}", ann);
2526
if x.len() > y.len() {
2627
x

0 commit comments

Comments
 (0)