1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-17 11:27:57 +02:00

Comprehensive Rust v2 (#1073)

I've taken some work by @fw-immunant and others on the new organization
of the course and condensed it into a form amenable to a text editor and
some computational analysis. You can see the inputs in `course.py` but
the interesting bits are the output: `outline.md` and `slides.md`.

The idea is to break the course into more, smaller segments with
exercises at the ends and breaks in between. So `outline.md` lists the
segments, their duration, and sums those durations up per-day. It shows
we're about an hour too long right now! There are more details of the
segments in `slides.md`, or you can see mostly the same stuff in
`course.py`.

This now contains all of the content from the v1 course, ensuring both
that we've covered everything and that we'll have somewhere to redirect
every page.

Fixes #1082.
Fixes #1465.

---------

Co-authored-by: Nicole LeGare <dlegare.1001@gmail.com>
Co-authored-by: Martin Geisler <mgeisler@google.com>
This commit is contained in:
Dustin J. Mitchell
2023-11-29 10:39:24 -05:00
committed by GitHub
parent ea204774b6
commit 6d19292f16
309 changed files with 6807 additions and 4281 deletions

View File

@ -1,4 +1,18 @@
# Paths
---
minutes: 10
---
# use, super, self
A module can bring symbols from another module into scope with `use`.
You will typically see something like this at the top of each module:
```rust,editable
use std::collections::HashSet;
use std::process::abort;
```
## Paths
Paths are resolved as follows:
@ -10,10 +24,29 @@ Paths are resolved as follows:
* `crate::foo` refers to `foo` in the root of the current crate,
* `bar::foo` refers to `foo` in the `bar` crate.
A module can bring symbols from another module into scope with `use`.
You will typically see something like this at the top of each module:
<details>
```rust,editable
use std::collections::HashSet;
use std::mem::transmute;
```
* It is common to "re-export" symbols at a shorter path. For example, the
top-level `lib.rs` in a crate might have
```rust,ignore
mod storage;
pub use storage::disk::DiskStorage;
pub use storage::network::NetworkStorage;
```
making `DiskStorage` and `NetworkStorage` available to other crates with a
convenient, short path.
* For the most part, only items that appear in a module need to be `use`'d.
However, a trait must be in scope to call any methods on that trait, even if
a type implementing that trait is already in scope. For example, to use the
`read_to_string` method on a type implementing the `Read` trait, you need to
`use std::io::Read`.
* The `use` statement can have a wildcard: `use std::io::*`. This is
discouraged because it is not clear which items are imported, and those might
change over time.
</details>