Skip to content

付録の和訳を最新版に更新 #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 56 commits into
base: master-ja
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
e685c96
ch02 数当てゲームのプログラミングの和訳を最新版に更新
shinmili May 26, 2024
db3a649
リンク漏れ修正
shinmili Nov 28, 2024
24f5af0
コメントの位置修正
shinmili Dec 26, 2024
cf8947f
ch03 一般的なプログラミングの概念の和訳を最新版に更新
shinmili May 26, 2024
42a63a5
リンク漏れ修正
shinmili Nov 28, 2024
e0d2a48
誤字修正
shinmili Jan 31, 2025
42cf09e
ch04 所有権を理解するの和訳を最新版に更新
shinmili May 26, 2024
138f7fc
コメント閉じ忘れ修正
shinmili Nov 28, 2024
f5f69e9
コードブロックの訳し漏れ修正
shinmili Nov 28, 2024
40d8fd5
ch05 構造体を使用して関係のあるデータを構造化するの和訳を最新版に更新
shinmili May 26, 2024
70c7a13
ch06 Enumとパターンマッチングの和訳を最新版に更新
shinmili May 26, 2024
2f70d34
ch07 肥大化していくプロジェクトをパッケージ、クレート、モジュールを利用して管理するの和訳を最新版に更新
shinmili May 26, 2024
0c0c9d5
消し忘れた段落を削除
shinmili Nov 29, 2024
9eb0aa4
読点の修正
shinmili Nov 29, 2024
1139c13
ch08 一般的なコレクションの和訳を最新版に更新
shinmili May 26, 2024
32a5e00
誤字修正
shinmili Nov 30, 2024
cbd1f9c
消し忘れた段落を削除
shinmili Nov 30, 2024
777e045
コメントの閉じ方の誤りを修正
shinmili Nov 30, 2024
6da5374
修正漏れを修正
shinmili Nov 30, 2024
75aeb75
doc.rust-lang.org 内でのみ機能する相対リンクを修正
shinmili Nov 30, 2024
93e7c99
ch09 エラー処理の和訳を最新版に更新
shinmili May 26, 2024
ee5f863
不要な記号の削除
shinmili Nov 30, 2024
1e6ccf0
消し忘れた段落を削除
shinmili Nov 30, 2024
4e664a9
コメントの位置修正
shinmili Dec 27, 2024
4e3d9ea
ch10 ジェネリック型、トレイト、ライフタイムの和訳を最新版に更新
shinmili May 26, 2024
439eeec
消し忘れた段落を削除
shinmili Nov 30, 2024
fb60cce
ch11 自動テストを書くの和訳を最新版に更新
shinmili May 26, 2024
91b9e1a
見出しレベル誤りを修正
shinmili Dec 1, 2024
059af4e
消し忘れた段落を削除
shinmili Dec 1, 2024
5464a6e
余計な空行を削除
shinmili Dec 27, 2024
06f787f
訳し漏れの翻訳を追加
shinmili Jan 31, 2025
fff91f0
誤字修正
shinmili Jan 31, 2025
57c5588
ch12 入出力プロジェクト: コマンドラインプログラムを構築するの和訳を最新版に更新
shinmili May 26, 2024
e042c99
ch13 関数型言語の機能: イテレータとクロージャの和訳を最新版に更新
shinmili May 26, 2024
4543380
見出しレベル誤りを修正
shinmili Dec 1, 2024
57b18f1
訳し忘れを修正
shinmili Dec 1, 2024
db47fd2
ch14 CargoとCrates.ioについてより詳しくの和訳を最新版に更新
shinmili May 26, 2024
e3bf9f9
ch15 スマートポインタの和訳を最新版に更新
shinmili May 26, 2024
e49e340
消し忘れた段落を削除
shinmili Dec 7, 2024
64432c2
ch16 恐れるな!並行性の和訳を最新版に更新
shinmili May 26, 2024
bd648eb
ch17 Rustのオブジェクト指向プログラミング機能の和訳を最新版に更新
shinmili May 26, 2024
7f4328c
ch18 パターンとマッチングの和訳を最新版に更新
shinmili May 26, 2024
46a06ad
ch19 高度な機能の和訳を最新版に更新
shinmili May 26, 2024
a8f53a5
markdown の誤りを修正
shinmili Dec 8, 2024
e657cc7
消し忘れた段落を削除
shinmili Dec 8, 2024
634ef1a
誤リンク修正
shinmili Jan 31, 2025
7351cd9
ch20 最後のプロジェクト: マルチスレッドのWebサーバを構築するの和訳を最新版に更新
shinmili May 26, 2024
d6477e2
付録A: キーワードの和訳をアップデート
shinmili May 26, 2024
07bc7e9
付録B: 演算子と記号の和訳をアップデート
shinmili May 26, 2024
8a44126
付録C: 導出可能なトレイトの和訳をアップデート
shinmili May 26, 2024
61796c9
付録D: 便利な開発ツールの和訳をアップデート
shinmili May 26, 2024
11c6f83
付録F: 本の翻訳の和訳をアップデート
shinmili May 26, 2024
6fb6df6
付録G: Rustの作られ方と“Nightly Rust”の和訳をアップデート
shinmili May 26, 2024
aceff44
訳し忘れを修正
shinmili Dec 8, 2024
ae12469
表内の行の削除・並び替えに合わせて修正
shinmili Dec 8, 2024
b5c6eaa
消し忘れた見出しを削除
shinmili Dec 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ch04 所有権を理解するの和訳を最新版に更新
  • Loading branch information
shinmili committed Feb 4, 2025
commit 42cf09ee05f030df3785b69feddcb8fa9b9d7f87
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fn main() {
// ANCHOR: here
{ // s is not valid here, it’s not yet declared
let s = "hello"; // s is valid from this point forward
{ // sは、ここでは有効ではない。まだ宣言されていない
let s = "hello"; // sは、ここから有効になる

// do stuff with s
} // this scope is now over, and s is no longer valid
// sで作業をする
} // このスコープは終わり。もうsは有効ではない
// ANCHOR_END: here
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
28 changes: 14 additions & 14 deletions listings/ch04-understanding-ownership/listing-04-03/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
fn main() {
let s = String::from("hello"); // s comes into scope
let s = String::from("hello"); // sがスコープに入る

takes_ownership(s); // s's value moves into the function...
// ... and so is no longer valid here
takes_ownership(s); // sの値が関数にムーブされ...
// ... ここではもう有効ではない

let x = 5; // x comes into scope
let x = 5; // xがスコープに入る

makes_copy(x); // x would move into the function,
// but i32 is Copy, so it’s okay to still
// use x afterward
makes_copy(x); // xも関数にムーブされるが、
// i32はCopyなので、この後にxを使っても
// 大丈夫

} // Here, x goes out of scope, then s. But because s's value was moved, nothing
// special happens.
} // ここでxがスコープを抜け、sもスコープを抜ける。ただし、sの値はムーブされているので、
// 何も特別なことは起こらない。

fn takes_ownership(some_string: String) { // some_string comes into scope
fn takes_ownership(some_string: String) { // some_stringがスコープに入る。
println!("{}", some_string);
} // Here, some_string goes out of scope and `drop` is called. The backing
// memory is freed.
} // ここでsome_stringがスコープを抜け、`drop`が呼ばれる。後ろ盾してたメモリが解放される。
// 後ろ盾してたメモリが解放される。

fn makes_copy(some_integer: i32) { // some_integer comes into scope
fn makes_copy(some_integer: i32) { // some_integerがスコープに入る
println!("{}", some_integer);
} // Here, some_integer goes out of scope. Nothing special happens.
} // ここでsome_integerがスコープを抜ける。何も特別なことはない。
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
34 changes: 15 additions & 19 deletions listings/ch04-understanding-ownership/listing-04-04/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
fn main() {
let s1 = gives_ownership(); // gives_ownership moves its return
// value into s1
let s1 = gives_ownership(); // gives_ownershipは、戻り値をs1に
// ムーブする

let s2 = String::from("hello"); // s2 comes into scope
let s2 = String::from("hello"); // s2がスコープに入る

let s3 = takes_and_gives_back(s2); // s2 is moved into
// takes_and_gives_back, which also
// moves its return value into s3
} // Here, s3 goes out of scope and is dropped. s2 goes out of scope but was
// moved, so nothing happens. s1 goes out of scope and is dropped.
let s3 = takes_and_gives_back(s2); // s2はtakes_and_gives_backにムーブされ
// 戻り値もs3にムーブされる
} // ここで、s3はスコープを抜け、ドロップされる。s2もスコープを抜けるが、ムーブされているので、
// 何も起きない。s1もスコープを抜け、ドロップされる。

fn gives_ownership() -> String { // gives_ownership will move its
// return value into the function
// that calls it
fn gives_ownership() -> String { // gives_ownershipは、戻り値を
// 呼び出した関数にムーブする

let some_string = String::from("hello"); // some_string comes into scope
let some_string = String::from("hello"); // some_stringがスコープに入る

some_string // some_string is returned and
// moves out to the calling
// function
some_string // some_stringが返され、呼び出し元関数に
// ムーブされる
}

// takes_and_gives_back will take a String and return one
fn takes_and_gives_back(a_string: String) -> String { // a_string comes into
// scope
// takes_and_gives_backは、Stringを一つ受け取り、返す。
fn takes_and_gives_back(a_string: String) -> String { // a_stringがスコープに入る。

a_string // a_string is returned and moves out to the calling function
a_string // a_stringが返され、呼び出し元関数にムーブされる
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ fn main() {

let (s2, len) = calculate_length(s1);

//'{}'の長さは、{}です
println!("The length of '{}' is {}.", s2, len);
}

fn calculate_length(s: String) -> (String, usize) {
let length = s.len(); // len() returns the length of a String
let length = s.len(); // len()メソッドは、Stringの長さを返します

(s, length)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
16 changes: 9 additions & 7 deletions listings/ch04-understanding-ownership/listing-04-06/output.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
$ cargo run
Compiling ownership v0.1.0 (file:///projects/ownership)
error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference
(`*some_string`は`&`参照の背後にあるため、それを可変として借用することはできません)
--> src/main.rs:8:5
|
7 | fn change(some_string: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
8 | some_string.push_str(", world");
| ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error: aborting due to previous error
| (`some_string`は`&`参照なので、それが指すデータを可変として借用することはできません)
|
help: consider changing this to be a mutable reference
(これを可変参照に変更することを検討してください)
|
7 | fn change(some_string: &mut String) {
| +++

For more information about this error, try `rustc --explain E0596`.
error: could not compile `ownership`.

To learn more, run the command again with --verbose.
error: could not compile `ownership` (bin "ownership") due to 1 previous error
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Carol (Nichols || Goulding) <carol.nichols@gmail.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
15 changes: 11 additions & 4 deletions listings/ch04-understanding-ownership/listing-04-09/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ fn first_word(s: &str) -> &str {
fn main() {
let my_string = String::from("hello world");

// first_word works on slices of `String`s
// first_wordは`String`のスライスに対して機能する
// `first_word` works on slices of `String`s, whether partial or whole
// `first_word`は`String`の全体または部分へのスライスに対して機能する
let word = first_word(&my_string[0..6]);
let word = first_word(&my_string[..]);
// `first_word` also works on references to `String`s, which are equivalent
// to whole slices of `String`s
// `first_word`は`String`の参照に対しても機能する。この場合は
// `String`全体へのスライスと同等。
let word = first_word(&my_string);

let my_string_literal = "hello world";

// first_word works on slices of string literals
// first_wordは文字列リテラルのスライスに対して機能する
// `first_word` works on slices of string literals, whether partial or whole
// `first_word`は文字列リテラルの全体または部分へのスライスに対して機能する
let word = first_word(&my_string_literal[0..6]);
let word = first_word(&my_string_literal[..]);

// Because string literals *are* string slices already,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ fn main() {
// ANCHOR: here
let mut s = String::from("hello");

s.push_str(", world!"); // push_str() appends a literal to a String
s.push_str(", world!"); // push_str()関数は、リテラルをStringに付け加える

println!("{}", s); // This will print `hello, world!`
println!("{}", s); // これは`hello, world!`と出力する
// ANCHOR_END: here
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
fn main() {
// ANCHOR: here
{
let s = String::from("hello"); // s is valid from this point forward
{
let s = String::from("hello"); // sはここから有効になる

// do stuff with s
} // this scope is now over, and s is no
// longer valid
// sで作業をする
} // このスコープはここでおしまい。sは
// もう有効ではない
// ANCHOR_END: here
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
$ cargo run
Compiling ownership v0.1.0 (file:///projects/ownership)
error[E0382]: borrow of moved value: `s1`
(ムーブされた値の借用: `s1`)
--> src/main.rs:5:28
|
2 | let s1 = String::from("hello");
| -- move occurs because `s1` has type `std::string::String`, which does not implement the `Copy` trait
| -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
| (`s1`は`String`型を持ち、これは`Copy`トレイトを実装していないので、ムーブが発生します)
3 | let s2 = s1;
| -- value moved here
4 |
| (ここで値がムーブされました)
4 |
5 | println!("{}, world!", s1);
| ^^ value borrowed here after move

error: aborting due to previous error
| (ムーブ後にここで借用されています)
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
3 | let s2 = s1.clone();
| ++++++++

For more information about this error, try `rustc --explain E0382`.
error: could not compile `ownership`.

To learn more, run the command again with --verbose.
error: could not compile `ownership` (bin "ownership") due to 1 previous error
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fn main() {
let len = calculate_length(&s1);
// ANCHOR_END: here

// '{}'の長さは、{}です
println!("The length of '{}' is {}.", s1, len);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ fn main() {
}

// ANCHOR: here
fn calculate_length(s: &String) -> usize { // s is a reference to a String
fn calculate_length(s: &String) -> usize { // sはStringへの参照
s.len()
} // Here, s goes out of scope. But because it does not have ownership of what
// it refers to, nothing happens.
} // ここで、sはスコープ外になる。けど、参照しているものの所有権を持っているわけではないので
// 何も起こらない
// ANCHOR_END: here
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy