Skip to content

Commit c031685

Browse files
authored
Update enum_use.md
Make code more idiomatic. A person learning Rust for the first time seeing `use crate::Role::*` gets spun into a rabbit hole of: - understanding what "crate::" means here - is a single file a crate? (look it up in the docs) - do even enums local to the file have to be specified with an absolute path from crate root? Besides, `use crate:: ...` is taught in the example for use later on, which is linked to at the bottom of this document. Using this document to only teach about unpacking enums into the name space, and then using the other document to introduce `use crate::`, means less things need to be learned all at once, reducing confusion.
1 parent 2c9b490 commit c031685

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/custom_types/enum/enum_use.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ enum Role {
1919
fn main() {
2020
// Explicitly `use` each name so they are available without
2121
// manual scoping.
22-
use crate::Stage::{Beginner, Advanced};
22+
use Stage::{Beginner, Advanced};
2323
// Automatically `use` each name inside `Role`.
24-
use crate::Role::*;
24+
use Role::*;
2525
2626
// Equivalent to `Stage::Beginner`.
2727
let stage = Beginner;

0 commit comments

Comments
 (0)