Skip to content

Commit ba0154a

Browse files
committed
make directories for sections to indicate directory structure clearly
1 parent 93f33d0 commit ba0154a

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
### 各コードの実行方法
1616

17-
`cargo workspace` 等の機能を使用しているので、実行には `cargo run` 以外にさらにいくつかオプションをつける必要があります。たとえば `chapter2``main_2_4_1.rs` を実行したい場合には、下記のように `cargo` コマンドを打つと実行できます。
17+
`cargo workspace` 等の機能を使用しているので、実行には `cargo run` 以外にさらにいくつかオプションをつける必要があります。たとえば `chapter2``2_4_1/main.rs` を実行したい場合には、下記のように `cargo` コマンドを打つと実行できます。
1818

1919
```bash
20-
cargo run -p chapter2 --bin main_2_4_1
20+
cargo run -p chapter2 --bin 2_4_1
2121
```
2222

2323
### Rust バージョン

chapter2/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ edition = "2018"
99
[dependencies]
1010

1111
[[bin]]
12-
name = "main_2_4_1"
13-
path = "src/main_2_4_1.rs"
12+
name = "2_4_1"
13+
path = "src/2_4_1/main.rs"
1414

1515
[[bin]]
16-
name = "main_2_4_2"
17-
path = "src/main_2_4_2.rs"
16+
name = "2_4_2"
17+
path = "src/2_4_2/main.rs"
1818

1919
[[bin]]
2020
name = "client_2_4_4"

chapter2/src/2_4_1/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std::fs::File;
2+
use std::io::Write;
3+
4+
fn main() -> std::io::Result<()> {
5+
let mut file = File::create("test.txt")?;
6+
file.write(b"std::fs::File example\n")?;
7+
Ok(())
8+
}

chapter2/src/2_4_2/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use std::io::{stdout, Write};
2+
3+
fn main() -> std::io::Result<()> {
4+
stdout().write(b"std::io::stdout example\n")?;
5+
Ok(())
6+
}

0 commit comments

Comments
 (0)