Skip to content

Commit 2de564b

Browse files
authored
Merge pull request #1820 from BooleanCat/master
ch07 - remove note regarding use and relative path
2 parents 44f1b71 + f749a74 commit 2de564b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ root, `hosting` is now a valid name in that scope, just as though the `hosting`
4141
module had been defined in the crate root. Paths brought into scope with `use`
4242
also check privacy, like any other paths.
4343

44-
Specifying a relative path with `use` is slightly different. Instead of
45-
starting from a name in the current scope, we must start the path given to
46-
`use` with the keyword `self`. Listing 7-12 shows how to specify a relative
47-
path to get the same behavior as in Listing 7-11.
44+
You can also bring an item into scope with `use` and a relative path. Listing
45+
7-12 shows how to specify a relative path to get the same behavior as in
46+
Listing 7-11.
4847

4948
<span class="filename">Filename: src/lib.rs</span>
5049

@@ -55,7 +54,7 @@ mod front_of_house {
5554
}
5655
}
5756

58-
use self::front_of_house::hosting;
57+
use front_of_house::hosting;
5958

6059
pub fn eat_at_restaurant() {
6160
hosting::add_to_waitlist();
@@ -66,10 +65,7 @@ pub fn eat_at_restaurant() {
6665
```
6766

6867
<span class="caption">Listing 7-12: Bringing a module into scope with `use` and
69-
a relative path starting with `self`</span>
70-
71-
Note that using `self` in this way might not be necessary in the future; it’s
72-
an inconsistency in the language that Rust developers are working to eliminate.
68+
a relative path</span>
7369

7470
### Creating Idiomatic `use` Paths
7571

0 commit comments

Comments
 (0)