1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-17 22:57:35 +02:00

Publish Comprehensive Rust 🦀

This commit is contained in:
Martin Geisler
2022-12-21 16:36:30 +01:00
commit c212a473ba
252 changed files with 8047 additions and 0 deletions

22
src/modules/filesystem.md Normal file
View File

@ -0,0 +1,22 @@
# Filesystem Hierarchy
The module content can be omitted:
```rust,editable,compile_fail
mod garden;
```
The `garden` module content is found at:
* `src/garden.rs` (modern Rust 2018 style)
* `src/garden/mod.rs` (older Rust 2015 style)
Similarly, a `garden::vegetables` module can be found at:
* `src/garden/vegetables.rs` (modern Rust 2018 style)
* `src/garden/vegetables/mod.rs` (older Rust 2015 style)
The `crate` root is in:
* `src/lib.rs` (for a library crate)
* `src/main.rs` (for a binary crate)

11
src/modules/paths.md Normal file
View File

@ -0,0 +1,11 @@
# Paths
Paths are resolved as follows:
1. As a relative path:
* `foo` or `self::foo` refers to `foo` in the current module,
* `super::foo` refers to `foo` in the parent module.
2. As an absolute path:
* `crate::foo` refers to `foo` in the root of the current crate,
* `bar::foo` refers to `foo` in the `bar` crate.

33
src/modules/visibility.md Normal file
View File

@ -0,0 +1,33 @@
# Visibility
Module are a privacy boundary:
* Module items are private by default (hides implementation details).
* Parent and sibling items are always visible.
```rust,editable
mod outer {
fn private() {
println!("outer::private");
}
pub fn public() {
println!("outer::public");
}
mod inner {
fn private() {
println!("outer::inner::private");
}
pub fn public() {
println!("outer::inner::public");
super::private();
}
}
}
fn main() {
outer::public();
}
```