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

Tutorial: Remove wildcard import of enum variants #750

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

skearya
Copy link

@skearya skearya commented Feb 22, 2024

In the channels section of the tutorial, a use statement imports all variants of the Command enum,

    while let Some(cmd) = rx.recv().await {
        use Command::*;

        match cmd {
            Get { key } => {
                client.get(&key).await;
            }
            Set { key, val } => {
                client.set(&key, val).await;
            }
        }
    }

This is bad practice because renaming / removing something in the Command enum doesn't cause a compile time error, like in a normal match statement, and creates a catch-all in the match.

Code_WJwujKAkVD.mp4

This PR just removes the use Command::* and changes the match statement to be on the full enum path in channels.md

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

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

Successfully merging this pull request may close these issues.

2 participants