Skip to content

Commit

Permalink
Show default Display implementations in the guide
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Jul 21, 2019
1 parent e09e947 commit efeb59b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/guide/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,34 @@ Each choice has the same capabilities. All of the fields of the
variant will be available and you can call methods on them, such
as `filename.display()`.

### The default `Display` implementation

It is recommended that you provide a value for `snafu(display)`, but
if it is omitted, the summary of the documentation comment will be
used. If that is not present, the name of the variant will be used.

```rust
# use snafu::Snafu;
#[derive(Debug, Snafu)]
enum Error {
/// No user available.
/// You may need to specify one.
MissingUser,
MissingPassword,
}

fn main() {
assert_eq!(
Error::MissingUser.to_string(),
"No user available. You may need to specify one.",
);
assert_eq!(
Error::MissingPassword.to_string(),
"MissingPassword",
);
}
```

## Controlling visibility

By default, each of the context selectors and their inherent
Expand Down

0 comments on commit efeb59b

Please sign in to comment.