Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implied bounds for Display and Error impl #148

merged 2 commits into from Sep 5, 2021

Implied bounds for Display and Error impl #148

merged 2 commits into from Sep 5, 2021


Copy link

@dtolnay dtolnay commented Sep 5, 2021

Closes #79. This PR enables an error type with generic parameter(s):

#[derive(Error, Debug)]
enum MyError<E, F> {
    #[error("thing {0}")]
    #[error("some error")]
    Delegate(#[source] F),

to emit appropriate impls, without further manual intervention to provide handwritten trait bounds. In the above case namely:

impl<E, F> Error for MyError<E, F>
    F: Error + 'static,
    Self: Debug + Display;

impl<E, F> Display for MyError<E, F>
    E: Display;

Implied bounds for error(transparent) are being done in an upcoming PR.

@dtolnay dtolnay merged commit e95b4ad into master Sep 5, 2021
12 checks passed
@dtolnay dtolnay deleted the bounds branch Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Generic type parameter on error
1 participant