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

implement chapter3_9 other than problem 3_9_6 #33

Merged
merged 7 commits into from May 4, 2021

Conversation

k-nasa
Copy link
Contributor

@k-nasa k-nasa commented May 1, 2021

ref: #16

3.9節の1~5までの実装を行いました。

3.9.6に関しては、golangだとio.multiReader, io.SectionReaderを使って得問題のようで、Rust標準には代替のものがボクの知る限りありません。multiReader, SectionReaderを実装するのは骨が折れますし問題の趣旨からずれそうなので一旦スキップしました。

Proof

以下動作確認ログになります。

3.9.1

❯ cargo run -p chapter3 --bin 3_9_1 chapter3/src/3_9_1/old.txt new.txt
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/3_9_1 chapter3/src/3_9_1/old.txt new.txt`

❯ cat new.txt
old text

3.9.2

❯ cargo run -p chapter3 --bin 3_9_2
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/3_9_2`

❯ wc -c random.txt
    1024 random.txt

3.9.3

❯ cargo run -p chapter3 --bin 3_9_3
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/3_9_3`

❯ unzip file.zip
Archive:  file.zip
  inflating: file.txt

❯ cat file.txt
zipzipzipzipzipzipzipzipzipzipzipzipzipzipzipzip

3.9.4

❯ cargo run -p chapter3 --bin 3_9_4

localhost:8080にアクセスすると次のファイルがダウンロードできる

スクリーンショット 2021-05-01 17 53 58

3.9.5

❯ echo "testtest" > test.txt

❯ cargo run -p chapter3 --bin 3_9_5
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/3_9_5`

❯ cat new_test.txt
test

@yuk1ty yuk1ty added オープン期間 誰でもコメントを残して、内容についてディスカッションできる期間にある PR です。 レビュー待ち レビューする必要があります。 labels May 1, 2021
@yuk1ty yuk1ty self-requested a review May 1, 2021 12:54
Copy link
Owner

@yuk1ty yuk1ty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!😃

@yuk1ty yuk1ty removed the レビュー待ち レビューする必要があります。 label May 1, 2021
@laysakura laysakura mentioned this pull request May 2, 2021
6 tasks
Copy link
Collaborator

@laysakura laysakura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全体的にほぼ良かったのですが、細かい点だけコメントしました 🙏

chapter3/src/3_9_1/old.txt Outdated Show resolved Hide resolved
chapter3/src/3_9_2/main.rs Outdated Show resolved Hide resolved
chapter3/src/3_9_5/main.rs Outdated Show resolved Hide resolved
k-nasa and others added 3 commits May 3, 2021 16:16
Co-authored-by: Sho Nakatani <lay.sakura@gmail.com>
Co-authored-by: Sho Nakatani <lay.sakura@gmail.com>
@k-nasa
Copy link
Contributor Author

k-nasa commented May 3, 2021

レビューありがとうございます 🙇
指摘いただいた箇所の修正は終わりました!

@laysakura
Copy link
Collaborator

@k-nasa 対応ありがとうございます。私のsuggestionを取り入れていただきましたが、空で書いたためそのままではビルドが通らずCIが落ちています...
動作確認 & commit & pushをお願いします。

@k-nasa
Copy link
Contributor Author

k-nasa commented May 3, 2021

🙈 すみません。完全に脳死していました。
buildが通ることを確認しました。


fn main() -> io::Result<()> {
let mut bytes = [0u8; 1024];
rand::thread_rng().fill(&mut bytes);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#33 (comment)

docを見るにgenでは最大で32要素しか埋められないらしく、fillを使うことにしました。

ref: https://docs.rs/rand/0.8.3/rand/trait.Rng.html#arrays-and-tuples

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうなんですね 😮 勉強になりました 🙏

@k-nasa k-nasa requested a review from laysakura May 3, 2021 12:50
Copy link
Collaborator

@laysakura laysakura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@yuk1ty
Copy link
Owner

yuk1ty commented May 4, 2021

マージします

@yuk1ty yuk1ty removed the オープン期間 誰でもコメントを残して、内容についてディスカッションできる期間にある PR です。 label May 4, 2021
@yuk1ty yuk1ty merged commit 3ccf088 into yuk1ty:master May 4, 2021
@k-nasa k-nasa deleted the replace_3_9_section branch May 5, 2021 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants