Skip to content

ch17 Rustのオブジェクト指向プログラミング機能の和訳を最新版に更新 #265

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 41 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
41 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
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
ch08 一般的なコレクションの和訳を最新版に更新
  • Loading branch information
shinmili committed Feb 4, 2025
commit 1139c138529790053dd07ba9645e5e47db106402
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-01/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

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

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

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

[dependencies]
18 changes: 13 additions & 5 deletions listings/ch08-common-collections/listing-08-04/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
fn main() {
// ANCHOR: here
{
let v = vec![1, 2, 3, 4];
let v = vec![1, 2, 3, 4, 5];

// vで作業をする
} // <- vはここでスコープを抜け、解放される
// ANCHOR_END: here
let third: &i32 = &v[2];
// "3つ目の要素は{third}です"
println!("The third element is {third}");

let third: Option<&i32> = v.get(2);
match third {
// "3つ目の要素は{third}です"
Some(third) => println!("The third element is {third}"),
// "3つ目の要素はありません。"
None => println!("There is no third element."),
}
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-05/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
11 changes: 2 additions & 9 deletions listings/ch08-common-collections/listing-08-05/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ fn main() {
// ANCHOR: here
let v = vec![1, 2, 3, 4, 5];

let third: &i32 = &v[2];
println!("The third element is {}", third);

match v.get(2) {
// "3つ目の要素は{}です"
Some(third) => println!("The third element is {}", third),
// "3つ目の要素はありません。"
None => println!("There is no third element."),
}
let does_not_exist = &v[100];
let does_not_exist = v.get(100);
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-06/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
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,18 +7,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immuta
4 | let first = &v[0];
| - immutable borrow occurs here
| (不変借用はここで発生しています)
5 |
5 |
6 | v.push(6);
| ^^^^^^^^^ mutable borrow occurs here
| (可変借用はここで発生しています)
7 |
8 | println!("The first element is: {}", first);
| ----- immutable borrow later used here
| (その後、不変借用はここで使われています)

error: aborting due to previous error
7 |
8 | println!("The first element is: {first}");
| ------- immutable borrow later used here
| (その後、不変借用はここで使われています)

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

To learn more, run the command again with --verbose.
error: could not compile `collections` (bin "collections") due to 1 previous error
10 changes: 7 additions & 3 deletions listings/ch08-common-collections/listing-08-06/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
fn main() {
// ANCHOR: here
let v = vec![1, 2, 3, 4, 5];
let mut v = vec![1, 2, 3, 4, 5];

let does_not_exist = &v[100];
let does_not_exist = v.get(100);
let first = &v[0];

v.push(6);

// "最初の要素は: {first}"
println!("The first element is: {first}");
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-07/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
11 changes: 4 additions & 7 deletions listings/ch08-common-collections/listing-08-07/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
fn main() {
// ANCHOR: here
let mut v = vec![1, 2, 3, 4, 5];

let first = &v[0];

v.push(6);

println!("The first element is: {}", first);
let v = vec![100, 32, 57];
for i in &v {
println!("{i}");
}
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-08/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
6 changes: 3 additions & 3 deletions listings/ch08-common-collections/listing-08-08/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn main() {
// ANCHOR: here
let v = vec![100, 32, 57];
for i in &v {
println!("{}", i);
let mut v = vec![100, 32, 57];
for i in &mut v {
*i += 50;
}
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-09/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
13 changes: 10 additions & 3 deletions listings/ch08-common-collections/listing-08-09/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
fn main() {
// ANCHOR: here
let mut v = vec![100, 32, 57];
for i in &mut v {
*i += 50;
enum SpreadsheetCell {
Int(i32),
Float(f64),
Text(String),
}

let row = vec![
SpreadsheetCell::Int(3),
SpreadsheetCell::Text(String::from("blue")),
SpreadsheetCell::Float(10.12),
];
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-10/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
16 changes: 5 additions & 11 deletions listings/ch08-common-collections/listing-08-10/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
fn main() {
// ANCHOR: here
enum SpreadsheetCell {
Int(i32),
Float(f64),
Text(String),
}
{
let v = vec![1, 2, 3, 4];

let row = vec![
SpreadsheetCell::Int(3),
SpreadsheetCell::Text(String::from("blue")),
SpreadsheetCell::Float(10.12),
];
// ANCHOR_END: here
// vで作業をする
} // <- vはここでスコープを抜け、解放される
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-11/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

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

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

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

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

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

[dependencies]
2 changes: 1 addition & 1 deletion listings/ch08-common-collections/listing-08-16/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ fn main() {
let mut s1 = String::from("foo");
let s2 = "bar";
s1.push_str(s2);
println!("s2 is {}", s2);
println!("s2 is {s2}");
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-17/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

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

[dependencies]
2 changes: 1 addition & 1 deletion listings/ch08-common-collections/listing-08-18/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fn main() {
// ANCHOR: here
let s1 = String::from("Hello, ");
let s2 = String::from("world!");
let s3 = s1 + &s2; // note s1 has been moved here and can no longer be used
let s3 = s1 + &s2; // s1はムーブされ、もう使用できないことに注意
// ANCHOR_END: here
}
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-19/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"
edition = "2021"

[dependencies]
25 changes: 16 additions & 9 deletions listings/ch08-common-collections/listing-08-19/output.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
$ cargo run
Compiling collections v0.1.0 (file:///projects/collections)
error[E0277]: the type `std::string::String` cannot be indexed by `{integer}`
--> src/main.rs:3:13
error[E0277]: the type `String` cannot be indexed by `{integer}`
(エラー: 型`String`は`{Integer}`で添え字アクセスできませんん)
--> src/main.rs:3:16
|
3 | let h = s1[0];
| ^^^^^ `std::string::String` cannot be indexed by `{integer}`
| ^ `String` cannot be indexed by `{integer}`
| (`String`は`{Integer}`で添え字アクセスできません)
|
= help: the trait `std::ops::Index<{integer}>` is not implemented for `std::string::String`

error: aborting due to previous error
= help: the trait `Index<{integer}>` is not implemented for `String`
(ヘルプ: `Index<{Integer}>`というトレイトが`String`に対して実装されていません)
= help: the following other types implement trait `Index<Idx>`:
(ヘルプ: 以下の型であればトレイト`Index<Idx>`を実装しています:)
<String as Index<RangeFull>>
<String as Index<std::ops::Range<usize>>>
<String as Index<RangeFrom<usize>>>
<String as Index<RangeTo<usize>>>
<String as Index<RangeInclusive<usize>>>
<String as Index<RangeToInclusive<usize>>>

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

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

[dependencies]
3 changes: 1 addition & 2 deletions listings/ch08-common-collections/listing-08-21/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[package]
name = "collections"
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