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

Update enum_use.md to use a more neutral theme #1828

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/custom_types/enum/enum_use.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ The `use` declaration can be used so manual scoping isn't needed:
// An attribute to hide warnings for unused code.
#![allow(dead_code)]

enum Status {
Rich,
Poor,
enum Stage {
Beginner,
Advanced,
}

enum Work {
Civilian,
Soldier,
enum Role {
Student,
Teacher,
}

fn main() {
// Explicitly `use` each name so they are available without
// manual scoping.
use crate::Status::{Poor, Rich};
// Automatically `use` each name inside `Work`.
use crate::Work::*;
use crate::Stage::{Beginner, Advanced};
// Automatically `use` each name inside `Role`.
use crate::Role::*;

// Equivalent to `Status::Poor`.
let status = Poor;
// Equivalent to `Work::Civilian`.
let work = Civilian;
// Equivalent to `Stage::Beginner`.
let stage = Beginner;
// Equivalent to `Role::Student`.
let role = Student;

match status {
match stage {
// Note the lack of scoping because of the explicit `use` above.
Rich => println!("The rich have lots of money!"),
Poor => println!("The poor have no money..."),
Beginner => println!("Beginners are starting their learning journey!"),
Advanced => println!("Advanced learners are mastering their subjects..."),
}

match work {
match role {
// Note again the lack of scoping.
Civilian => println!("Civilians work!"),
Soldier => println!("Soldiers fight!"),
Student => println!("Students are acquiring knowledge!"),
Teacher => println!("Teachers are spreading knowledge!"),
}
}
```
Expand Down
Loading