diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-03-08 13:58:14 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-03-09 16:48:05 -0400 |
| commit | bc927a69b2967ccff3ba0a0cc7a8f6829dbf7cfd (patch) | |
| tree | 1af749e836b594ae3b5361bc3dde089e2c957054 /src | |
| parent | ead9ab84b80ba3b172d529b1d2a2917bb05b4820 (diff) | |
| download | rust-bc927a69b2967ccff3ba0a0cc7a8f6829dbf7cfd.tar.gz rust-bc927a69b2967ccff3ba0a0cc7a8f6829dbf7cfd.zip | |
Explain super in the crates guide.
Fixes #19808
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/trpl/crates-and-modules.md | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/doc/trpl/crates-and-modules.md b/src/doc/trpl/crates-and-modules.md index f3c0195855c..8eaad5067f0 100644 --- a/src/doc/trpl/crates-and-modules.md +++ b/src/doc/trpl/crates-and-modules.md @@ -555,6 +555,13 @@ Here we have a `pub use` for each function we want to bring into the `japanese` scope. We could alternatively use the wildcard syntax to include everything from `greetings` into the current scope: `pub use self::greetings::*`. +What about the `self`? Well, by default, `use` declarations are absolute paths, +starting from your crate root. `self` makes that path relative to your current +place in the hierarchy instead. There's one more special form of `use`: you can +`use super::` to reach one level up the tree from your current location. Some +people like to think of `self` as `.` and `super` as `..`, from many shells' +display for the current directory and the parent directory. + Also, note that we `pub use`d before we declared our `mod`s. Rust requires that `use` declarations go first. |
