Skip to content

ch20 最後のプロジェクト: マルチスレッドのWebサーバを構築するの和訳を最新版に更新 #268

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 47 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
47 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
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
ch18 パターンとマッチングの和訳を最新版に更新
  • Loading branch information
shinmili committed Feb 4, 2025
commit 7f4328c3178c54e3646b41dff0548a00f628aaa2
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-01/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
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 @@ -4,16 +4,21 @@ fn main() {
let age: Result<u8, _> = "34".parse();

if let Some(color) = favorite_color {
println!("Using your favorite color, {}, as the background", color);
// "あなたのお気に入りの色、{color}を背景色に使用します"
println!("Using your favorite color, {color}, as the background");
} else if is_tuesday {
// "火曜日は緑の日!"
println!("Tuesday is green day!");
} else if let Ok(age) = age {
if age > 30 {
// "紫を背景色に使用します"
println!("Using purple as the background color");
} else {
// "オレンジを背景色に使用します"
println!("Using orange as the background color");
}
} else {
// "青を背景色に使用します"
println!("Using blue as the background color");
}
}
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-02/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-03/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-04/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-05/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
12 changes: 6 additions & 6 deletions listings/ch18-patterns-and-matching/listing-18-05/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ error[E0308]: mismatched types
--> src/main.rs:2:9
|
2 | let (x, y) = (1, 2, 3);
| ^^^^^^ expected a tuple with 3 elements, found one with 2 elements
| ^^^^^^ --------- this expression has type `({integer}, {integer}, {integer})`
| | (この式は型`({integer}, {integer}, {integer})`を持ちます)
| |
| expected a tuple with 3 elements, found one with 2 elements
| (3要素のタプルを予期したのに、2要素のタプルが見つかりました)
|
= note: expected tuple `({integer}, {integer}, {integer})`
found tuple `(_, _)`

error: aborting due to previous error

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

To learn more, run the command again with --verbose.
error: could not compile `patterns` (bin "patterns") due to 1 previous error
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-06/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-07/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
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,4 +1,5 @@
fn print_coordinates(&(x, y): &(i32, i32)) {
// "現在の位置: ({}, {})"
println!("Current location: ({}, {})", x, y);
}

Expand Down
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-08/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
21 changes: 12 additions & 9 deletions listings/ch18-patterns-and-matching/listing-18-08/output.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
$ cargo run
Compiling patterns v0.1.0 (file:///projects/patterns)
error[E0005]: refutable pattern in local binding: `None` not covered
error[E0005]: refutable pattern in local binding
(エラー: ローカル束縛に論駁可能なパターン)
--> src/main.rs:3:9
|
3 | let Some(x) = some_option_value;
| ^^^^^^^ pattern `None` not covered
| (パターン`None`がカバーされていません)
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
(注釈: `let`束縛は`struct`や単一の列挙子を持つ`enum`などの「論駁不可能なパターン」を必要とします)
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
help: you might want to use `if let` to ignore the variant that isn't matched
(注釈: さらなる情報についてはhttps://doc.rust-lang.org/book/ch18-02-refutability.htmlを確認してください)
= note: the matched value is of type `Option<i32>`
(注釈: マッチ対象の値は`Option<i32>`型を持ちます)
help: you might want to use `let else` to handle the variant that isn't matched
(ヘルプ: マッチしない列挙子を処理するために`let else`を使用するといいかもしれません)
|
3 | if let Some(x) = some_option_value { /* */ }
|

error: aborting due to previous error
3 | let Some(x) = some_option_value else { todo!() };
| ++++++++++++++++

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

To learn more, run the command again with --verbose.
error: could not compile `patterns` (bin "patterns") due to 1 previous error
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-09/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-10/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
17 changes: 11 additions & 6 deletions listings/ch18-patterns-and-matching/listing-18-10/output.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
$ cargo run
Compiling patterns v0.1.0 (file:///projects/patterns)
warning: irrefutable if-let pattern
--> src/main.rs:2:5
warning: irrefutable `if let` pattern
(警告: 論駁不可能な`if let`パターン)
--> src/main.rs:2:8
|
2 | / if let x = 5 {
3 | | println!("{}", x);
4 | | };
| |_____^
2 | if let x = 5 {
| ^^^^^^^^^
|
= note: this pattern will always match, so the `if let` is useless
(注釈: このパターンは常にマッチするので`if let`は無意味です)
= help: consider replacing the `if let` with a `let`
(ヘルプ: `if let`を`let`で置き換えることを検討してください)
= note: `#[warn(irrefutable_let_patterns)]` on by default
(注釈: `#[warn(irrefutable_let_patterns)]`はデフォルトでオンです)

warning: `patterns` (bin "patterns") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.39s
Running `target/debug/patterns`
5
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-11/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
8 changes: 6 additions & 2 deletions listings/ch18-patterns-and-matching/listing-18-11/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ fn main() {
let y = 10;

match x {
// 50だったよ
Some(50) => println!("Got 50"),
Some(y) => println!("Matched, y = {:?}", y),
// マッチしたよ、y = {y}
Some(y) => println!("Matched, y = {y}"),
// 既定のケース、x = {:?}
_ => println!("Default case, x = {:?}", x),
}

println!("at the end: x = {:?}, y = {:?}", x, y);
// 最後には: x = {:?}, y = {y}
println!("at the end: x = {:?}, y = {y}", x);
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-12/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-13/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-14/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
11 changes: 8 additions & 3 deletions listings/ch18-patterns-and-matching/listing-18-14/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ fn main() {
let p = Point { x: 0, y: 7 };

match p {
Point { x, y: 0 } => println!("On the x axis at {}", x),
Point { x: 0, y } => println!("On the y axis at {}", y),
Point { x, y } => println!("On neither axis: ({}, {})", x, y),
// x軸上の{x}
Point { x, y: 0 } => println!("On the x axis at {x}"),
// y軸上の{y}
Point { x: 0, y } => println!("On the y axis at {y}"),
// どちらの軸上でもない: ({x}, {y})
Point { x, y } => {
println!("On neither axis: ({x}, {y})");
}
}
}
// ANCHOR_END: here
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-15/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
22 changes: 12 additions & 10 deletions listings/ch18-patterns-and-matching/listing-18-15/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ fn main() {

match msg {
Message::Quit => {
println!("The Quit variant has no data to destructure.")
// Quit列挙子には分配すべきデータがない
println!("The Quit variant has no data to destructure.");
}
Message::Move { x, y } => {
println!(
"Move in the x direction {} and in the y direction {}",
x, y
);
// x方向に{x}、y方向に{y}だけ動く
println!("Move in the x direction {x} and in the y direction {y}");
}
Message::Write(text) => {
// テキストメッセージ: {text}
println!("Text message: {text}");
}
Message::ChangeColor(r, g, b) => {
// 色を赤{r}, 緑{g}, 青{b}に変更
println!("Change the color to red {r}, green {g}, and blue {b}",)
}
Message::Write(text) => println!("Text message: {}", text),
Message::ChangeColor(r, g, b) => println!(
"Change the color to red {}, green {}, and blue {}",
r, g, b
),
}
}
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-16/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
16 changes: 8 additions & 8 deletions listings/ch18-patterns-and-matching/listing-18-16/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ fn main() {
let msg = Message::ChangeColor(Color::Hsv(0, 160, 255));

match msg {
Message::ChangeColor(Color::Rgb(r, g, b)) => println!(
"Change the color to red {}, green {}, and blue {}",
r, g, b
),
Message::ChangeColor(Color::Hsv(h, s, v)) => println!(
"Change the color to hue {}, saturation {}, and value {}",
h, s, v
),
Message::ChangeColor(Color::Rgb(r, g, b)) => {
// 色を赤{r}, 緑{g}, 青{b}に変更
println!("Change color to red {r}, green {g}, and blue {b}");
}
Message::ChangeColor(Color::Hsv(h, s, v)) => {
// 色を色相{h}, 彩度{s}, 明度{v}に変更
println!("Change color to hue {h}, saturation {s}, value {v}")
}
_ => (),
}
}
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-17/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
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,4 +1,5 @@
fn foo(_: i32, y: i32) {
// このコードは、y引数を使うだけです: {}
println!("This code only uses the y parameter: {}", y);
}

Expand Down
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-18/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
2 changes: 2 additions & 0 deletions listings/ch18-patterns-and-matching/listing-18-18/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ fn main() {

match (setting_value, new_setting_value) {
(Some(_), Some(_)) => {
// 既存の値の変更を上書きできません
println!("Can't overwrite an existing customized value");
}
_ => {
setting_value = new_setting_value;
}
}

// 設定は{:?}です
println!("setting is {:?}", setting_value);
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch18-patterns-and-matching/listing-18-19/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "patterns"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
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