yuk1ty / learning-systems-programming-in-rust

「Rustでもわかるシステムプログラミング」
430 stars 23 forks source link

add 9.5.1 - 9.5.3 #72

Closed shnmorimoto closed 3 years ago

shnmorimoto commented 3 years ago

対象の Issue

60 9.5.1 - 9.5.3

動作確認結果

9.5.1

Go 実行結果

> go run main.go
Temp File Path: /tmp/temp.txt

Rust 実行結果

> cargo run -p chapter9 --bin 9_5_1
Temp File Path: /tmp/temp.txt

9.5.2

Go 実行結果

> go run main.go
Dir: /folder1/folder2/, Name: example.txt
[ folder1 folder2 example.txt]
example.txt
/folder1/folder2
.txt

Rust 実行結果

> cargo run -p chapter9 --bin 9_5_2
Dir: /folder1/folder2, Name: example.txt
["/", "folder1", "folder2", "example.txt"]
example.txt
/folder1/folder2
txt

9.5.3

Go 実行結果

存在しないパターン
> go run main.go hoge
exit status 1
> echo $?
1

存在するパターン
> go run main.go go
/usr/local/go/bin/go

Rust 実行結果

存在しないパターン
> cargo run -p chapter9 --bin 9_5_3 hoge
> echo $?
1

存在するパターン
> cargo run -p chapter9 --bin 9_5_3 go
/usr/local/go/bin/go