From c0316850626dc523ba0ccd5d63f323f6f205dd9c Mon Sep 17 00:00:00 2001 From: cheater <195390+cheater@users.noreply.github.com> Date: Mon, 22 Sep 2025 07:30:52 +0200 Subject: [PATCH] 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. --- src/custom_types/enum/enum_use.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom_types/enum/enum_use.md b/src/custom_types/enum/enum_use.md index 80a86e1400..75d419fe79 100644 --- a/src/custom_types/enum/enum_use.md +++ b/src/custom_types/enum/enum_use.md @@ -19,9 +19,9 @@ enum Role { fn main() { // Explicitly `use` each name so they are available without // manual scoping. - use crate::Stage::{Beginner, Advanced}; + use Stage::{Beginner, Advanced}; // Automatically `use` each name inside `Role`. - use crate::Role::*; + use Role::*; // Equivalent to `Stage::Beginner`. let stage = Beginner;