Skip to content
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

ch15 スマートポインタの和訳を最新版に更新 #263

Open
wants to merge 17 commits into
base: master-ja
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
499278e
ch00 はじめにの和訳を最新版に更新
shinmili May 26, 2024
7573273
ch01 事始めの和訳を最新版に更新
shinmili May 26, 2024
cc34c09
ch02 数当てゲームのプログラミングの和訳を最新版に更新
shinmili May 26, 2024
49f93be
ch03 一般的なプログラミングの概念の和訳を最新版に更新
shinmili May 26, 2024
005ab57
ch04 所有権を理解するの和訳を最新版に更新
shinmili May 26, 2024
7dce9e1
ch05 構造体を使用して関係のあるデータを構造化するの和訳を最新版に更新
shinmili May 26, 2024
0de9bcf
ch06 Enumとパターンマッチングの和訳を最新版に更新
shinmili May 26, 2024
20bed51
ch07 肥大化していくプロジェクトをパッケージ、クレート、モジュールを利用して管理するの和訳を最新版に更新
shinmili May 26, 2024
d2d9bbb
ch08 一般的なコレクションの和訳を最新版に更新
shinmili May 26, 2024
0f629e7
ch09 エラー処理の和訳を最新版に更新
shinmili May 26, 2024
4eabca9
ch10 ジェネリック型、トレイト、ライフタイムの和訳を最新版に更新
shinmili May 26, 2024
09725f3
ch11 自動テストを書くの和訳を最新版に更新
shinmili May 26, 2024
fcc533b
ch12 入出力プロジェクト: コマンドラインプログラムを構築するの和訳を最新版に更新
shinmili May 26, 2024
239347a
ch13 関数型言語の機能: イテレータとクロージャの和訳を最新版に更新
shinmili May 26, 2024
2296c28
ch14 CargoとCrates.ioについてより詳しくの和訳を最新版に更新
shinmili May 26, 2024
97d8397
ch15 スマートポインタの和訳を最新版に更新
shinmili May 26, 2024
f35ad6c
消し忘れた段落を削除
shinmili Dec 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions dot/trpl15-04.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
digraph {
node[shape=record];
rankdir=LR;

l1[label="{<data> 5| <next>}"];
l2[label="{<data> 10| <next>}"];

{node[shape=point height=0] invisible_start invisible_end}

a -> l1:n;
b -> l2:n;
invisible_start:n -> l1[arrowtail=none];
invisible_start:s -> invisible_end:s[dir=none];
l1:next:c -> l2:data;
l2:next:c -> invisible_end:n[arrowhead=none];
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
// ANCHOR_END: expect

// ANCHOR: print_guess
println!("You guessed: {}", guess); // 次のように予想しました: {}
println!("You guessed: {guess}"); // 次のように予想しました: {guess}
// ANCHOR_END: print_guess
}
// ANCHOR: all
40 changes: 16 additions & 24 deletions listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.3"
rand = "0.8.5"
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ fn main() {
.read_line(&mut guess)
.expect("Failed to read line");

println!("You guessed: {}", guess);
println!("You guessed: {guess}");
}
16 changes: 4 additions & 12 deletions listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.3"
rand = "0.8.5"
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ fn main() {
println!("Guess the number!");

// ANCHOR: ch07-04
let secret_number = rand::thread_rng().gen_range(1..101);
let secret_number = rand::thread_rng().gen_range(1..=100);
// ANCHOR_END: ch07-04

println!("The secret number is: {}", secret_number); //秘密の数字は次の通り: {}
println!("The secret number is: {secret_number}"); //秘密の数字は次の通り: {secret_number}

println!("Please input your guess.");

Expand All @@ -21,7 +21,7 @@ fn main() {
.read_line(&mut guess)
.expect("Failed to read line");

println!("You guessed: {}", guess);
println!("You guessed: {guess}");
// ANCHOR: ch07-04
}
// ANCHOR_END: ch07-04
Expand Down
16 changes: 4 additions & 12 deletions listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.3"
rand = "0.8.5"
40 changes: 10 additions & 30 deletions listings/ch02-guessing-game-tutorial/listing-02-04/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,22 @@ $ cargo build
Compiling ppv-lite86 v0.2.10
Compiling rand_core v0.6.2
Compiling rand_chacha v0.3.0
Compiling rand v0.8.3
Compiling rand v0.8.5
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
error[E0308]: mismatched types (型が合いません)
--> src/main.rs:22:21
|
22 | match guess.cmp(&secret_number) {
| ^^^^^^^^^^^^^^ expected struct `String`, found integer
| (構造体`std::string::String`を予期したけど、整数型変数が見つかりました)
| --- ^^^^^^^^^^^^^^ expected `&String`, found `&{integer}`
| | (`&String`を予期したけど、`&{integer}`が見つかりました)
| |
| arguments to this method are incorrect
| (このメソッドへの引数が正しくありません)
|
= note: expected reference `&String`
found reference `&{integer}`
note: method defined here
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/cmp.rs:814:8

error[E0283]: type annotations needed for `{integer}`
--> src/main.rs:8:44
|
8 | let secret_number = rand::thread_rng().gen_range(1..101);
| ------------- ^^^^^^^^^ cannot infer type for type `{integer}`
| |
| consider giving `secret_number` a type
|
= note: multiple `impl`s satisfying `{integer}: SampleUniform` found in the `rand` crate:
- impl SampleUniform for i128;
- impl SampleUniform for i16;
- impl SampleUniform for i32;
- impl SampleUniform for i64;
and 8 more
note: required by a bound in `gen_range`
--> /Users/carolnichols/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.8.3/src/rng.rs:129:12
|
129 | T: SampleUniform,
| ^^^^^^^^^^^^^ required by this bound in `gen_range`
help: consider specifying the type arguments in the function call
|
8 | let secret_number = rand::thread_rng().gen_range::<T, R>(1..101);
| ++++++++

Some errors have detailed explanations: E0283, E0308.
For more information about an error, try `rustc --explain E0283`.
error: could not compile `guessing_game` due to 2 previous errors (先の2つのエラーのため、`guessing_game`をコンパイルできませんでした)
For more information about this error, try `rustc --explain E0308`.
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error (先の1つのエラーのため、`guessing_game` (bin "guessing_game") をコンパイルできませんでした)
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ fn main() {
// ANCHOR_END: here
println!("Guess the number!");

let secret_number = rand::thread_rng().gen_range(1..101);
let secret_number = rand::thread_rng().gen_range(1..=100);

println!("The secret number is: {}", secret_number);
println!("The secret number is: {secret_number}");

println!("Please input your guess.");

Expand All @@ -21,7 +21,7 @@ fn main() {
.expect("Failed to read line");
// ANCHOR: here

println!("You guessed: {}", guess);
println!("You guessed: {guess}");

match guess.cmp(&secret_number) {
Ordering::Less => println!("Too small!"), //小さすぎ!
Expand Down
16 changes: 4 additions & 12 deletions listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.3"
rand = "0.8.5"
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::io;
fn main() {
println!("Guess the number!");

let secret_number = rand::thread_rng().gen_range(1..101);
let secret_number = rand::thread_rng().gen_range(1..=100);

println!("The secret number is: {}", secret_number);
println!("The secret number is: {secret_number}");

loop {
println!("Please input your guess.");
Expand All @@ -28,7 +28,7 @@ fn main() {
};
// ANCHOR_END: ch19

println!("You guessed: {}", guess);
println!("You guessed: {guess}");

// --snip--
// ANCHOR_END: here
Expand Down
Loading