Skip to content

chore: when use match pattern, we use result as variable name in the success path #31

@EiffelFly

Description

@EiffelFly

Context

Currently, we use this match pattern in our backend

let discord_message =
        match db_third_party::discord::DiscordMessage::create(client, &payload).await {
            Ok(discord_message) => discord_message,
            Err(error) => {
                return Err((
                    StatusCode::INTERNAL_SERVER_ERROR,
                    format!(
                        "Something went wrong when create discord message: {}",
                        error
                    ),
                )
                    .into_response())
            }
        };

In order to reduce the overhead of coming up a variable name for Ok(), I purpose that we unify that as below

let discord_message =
        match db_third_party::discord::DiscordMessage::create(client, &payload).await {
            Ok(result) => result,
            Err(error) => {
                return Err((
                    StatusCode::INTERNAL_SERVER_ERROR,
                    format!(
                        "Something went wrong when create discord message: {}",
                        error
                    ),
                )
                    .into_response())
            }
        };

Instead of coming up a new name, we use result

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions