Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Allow variant with no #fail attribute #245

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kngwyu
Copy link

@kngwyu kngwyu commented Aug 17, 2018

If a variant doesn't have fail attribute, use its' name to display.
E.g.

#[derive(Debug, Fail)]
struct StructWithNoAttr;

#[test]
fn struct_with_no_attr() {
    let s = format!("{}", StructWithNoAttr {});
    assert_eq!(&s[..], "StructWithNoAttr");
}

I don't think All variants must have display attribute is user friendly, but feel free to close this PR if you don't like it.

If a variant doesn't have fail atrribute, use its' name to display
@dekellum
Copy link

dekellum commented Aug 17, 2018

I like the high level feature concept. But is this not what Debug offers already? Should the Debug::fmt be what is actually used as a fallback for no "display attribute", e.g. or_else(|| format!("{:?}", self)) ?

@kngwyu
Copy link
Author

kngwyu commented Aug 18, 2018

Should the Debug::fmt be what is actually used as a fallback for no "display attribute"

Agreed, I modified to do so.

@kngwyu
Copy link
Author

kngwyu commented Aug 18, 2018

Now I noticed it's a breaking change.
Like https://github.com/rust-lang-nursery/failure/blob/master/failure_derive/tests/no_derive_display.rs , now we can write manual implementation if a struct/enum derives Fail and it has no fail attribute.
So Display implementation can cause conflicts 😓

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants