Skip to content

Deriving Error with Eq #372

@Nekidev

Description

@Nekidev

It's a little thing and it's good for ergonomics when checking whether an error occurred or if the row did not exist when using ::get() to be able to do

match result {
    Ok(_) => unimplemented!(),
    Err(e) => {
        if e == Error::NoSuchObject {
            // ...
        } else {
            // ...
        }

        // VS.

        match e {
            Error::NoSuchObject => {
                // ...
            },
            _ => {
                // ...
            }
        }
    }
}

It's prettier than having to nest another match to check for one of all the possible errors (less lines of code and less nesting for the same purpose). This is implemented by deriving the Error enum with:

#[derive(PartialEq, Eq)]
pub enum Error {
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions