Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of use declaration seems contradicting the rust lang book #1390

Closed
ejez opened this issue Nov 27, 2020 · 1 comment
Closed

Use of use declaration seems contradicting the rust lang book #1390

ejez opened this issue Nov 27, 2020 · 1 comment

Comments

@ejez
Copy link
Contributor

ejez commented Nov 27, 2020

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 easier
access. It is often used like this:

use crate::deeply::nested::{
    my_first_function,
    my_second_function,
    AndATraitType
};

================================================================
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 the
function’s parent module
into scope with use so we have to specify the parent
module 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.

@marioidival
Copy link
Member

Hi, I'm closing this issue just to clean up the items that already exist. If you think this issue makes sense to stay open, please create a new issue with updated information and mention this one.

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants