Skip to content

Conversation

@shepmaster
Copy link
Owner

TL;DR, SNAFU learns this:

#[derive(Debug, Snafu)]
#[snafu(source(from(generic)))]
struct OuterError(MiddleError);

which effectively generates this implementation:

impl<Source> From<Source> for OuterError
where
    Source: Into<MiddleError>,
{
    fn from(error: Source) -> Self {
        OuterError(error.into())
    }
}

This applies to

  • opaque errors
  • context(false)
  • transparent

Resolves #481, resolves #518

@shepmaster shepmaster added the enhancement New feature or request label Dec 8, 2025
@netlify
Copy link

netlify bot commented Dec 8, 2025

Deploy Preview for shepmaster-snafu ready!

Name Link
🔨 Latest commit e174405
🔍 Latest deploy log https://app.netlify.com/projects/shepmaster-snafu/deploys/69370ef9b10ce800089cdea0
😎 Deploy Preview https://deploy-preview-537--shepmaster-snafu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Adds `from(generic)` and `from(exact)` to the existing `from(type,
transform)`.

This impacts
- opaque errors
- `context(false)`
- `transparent`

Gotchas:

- Transforming a type called `exact` or `generic` will not work
  anymore. You'll need to call it `r#exact` or `r#generic`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for impl From<T> for ErrorEnum where T: Into<OneVariantsSource> Generate From<source> implementations for opaque error

2 participants