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

05_tickets_v2 03_variants_with_data.md Bindigs explanation error #211

Open
kurbanboi opened this issue Nov 12, 2024 · 0 comments
Open

05_tickets_v2 03_variants_with_data.md Bindigs explanation error #211

kurbanboi opened this issue Nov 12, 2024 · 0 comments

Comments

@kurbanboi
Copy link

kurbanboi commented Nov 12, 2024

Bindings

In the match pattern Status::InProgress { assigned_to }, assigned_to is a binding.
We're destructuring the Status::InProgress variant and binding the assigned_to field to
a new variable,

[also named assigned_to.] <= this should be [named person]

If we wanted, we could bind the field to a different variable name:

match status {
    Status::InProgress { assigned_to: person } => {
        println!("Assigned to: {}", person);
    },
    Status::ToDo | Status::Done => {
        println!("Done");
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant