You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-24 09:46:45 +02:00
Day2: Afternoon - speaker note details and minor cosmetic changes. (#408)
* A few speaker notes in Day2: Afternoon and minor cosmetic changes. * Do not test filesystem example code block.
This commit is contained in:
@ -20,3 +20,34 @@ The `crate` root is in:
|
||||
|
||||
* `src/lib.rs` (for a library crate)
|
||||
* `src/main.rs` (for a binary crate)
|
||||
|
||||
<details>
|
||||
|
||||
* The change from `module/mod.rs` to `module.rs` doesn't preclude the use of submodules in Rust 2018.
|
||||
(It was mandatory in Rust 2015.)
|
||||
|
||||
The following is valid:
|
||||
|
||||
```ignore
|
||||
src/
|
||||
├── main.rs
|
||||
├── top_module.rs
|
||||
└── top_module/
|
||||
└── sub_module.rs
|
||||
```
|
||||
|
||||
* The main reason for the change is to prevent many files named `mod.rs`, which can be hard
|
||||
to distinguish in IDEs.
|
||||
|
||||
* Rust will look for modules in `modulename/mod.rs` and `modulename.rs`, but this can be changed
|
||||
with a compiler directive:
|
||||
|
||||
```rust,ignore
|
||||
#[path = "some/path.rs"]
|
||||
mod some_module { }
|
||||
```
|
||||
|
||||
This is useful, for example, if you would like to place tests for a module in a file named
|
||||
`some_module_test.rs`, similar to the convention in Go.
|
||||
|
||||
</details>
|
||||
|
Reference in New Issue
Block a user