Skip to content

Allow #[error(transparent)] on fieldsΒ #103

Open
@djc

Description

The crate I'm currently working on has code like the following:

#[derive(Debug, Clone, Error)]
pub struct Error {
    pub(crate) kind: ErrorKind,
    backtrack: Option<ExtBacktrace>,
}

#[derive(Debug, Error)]
pub enum ErrorKind {
    // error variants go here
}

If I understand correctly, this doesn't currently allow the Error impl for Error to return types from the ErrorKind variants, which seems like it would be useful. I thought I might try #[error(transparent)] on Error's kind field, but that's not allowed. Is there currently a way to support this scenario? From the description of error(transparent) it seems like it would be a good fit for this, but maybe there's a good reason not to allow this.

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