Skip to content

support for struct-like variants? #5

Closed
@colin-kiegel

Description

@colin-kiegel

This is a great library. 👍

One thing I am missing is struct-like variants:

quick_error! {
    #[derive(Debug)]
    pub enum IoWrapper {
        IoAt(place: &'static str, err: io::Error) {}
    }
}

let err = IoWrapper::IoAt {
    place: unimplemented!(),
    err: unimplemented!()
}  // compile error: `IoWrapper::IoAt` does not name a structure 

Support for struct-like variants would be great AND it would help migrating some existing error definitions to quick-error.

I just checked: std-lib uses struct-like variants for some error enums too:

  • std::str::Utf8Error
  • std::sync::PoisonError
  • std::string::FromUtf8Error

So there seem to be use cases to use both kind of variants. Is it generally possible to implement at all? If so, the syntax could be curly-braces IoAt{place: ..} {} instead of round-braces IoAt(place: ..) {}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions