Use of use
declaration seems contradicting the rust lang book
#1390
Labels
use
declaration seems contradicting the rust lang book
#1390
Quoting from https://doc.rust-lang.org/rust-by-example/mod/use.html :
The
use
declaration can be used to bind a full path to a new name, for easieraccess. It is often used like this:
================================================================
Now quoting from https://doc.rust-lang.org/stable/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html :
Although both Listing 7-11 and 7-13 accomplish the same task, Listing 7-11 is
the idiomatic way to bring a function into scope with
use
. Bringing thefunction’s parent module into scope with
use
so we have to specify the parentmodule when calling the function makes it clear that the function isn’t locally
defined while still minimizing repetition of the full path. The code in Listing
7-13 is unclear as to where
add_to_waitlist
is defined.On the other hand, when bringing in structs, enums, and other items with
use
,it’s idiomatic to specify the full path.
The text was updated successfully, but these errors were encountered: