Skip to content

Commit

Permalink
doc: Add example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmah309 committed Sep 10, 2024
1 parent f3fb3e7 commit 223f9a5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,30 @@ error_set! {
B,
IoError(std::io::Error),
};
Y = {
SetY = {
C,
} || X;
} || SetX;
}
```
<details>

<summary>Usage</summary>

```rust
fn main() {
let x = SetX::A {
name: "john".to_string(),
age: 32,
};
assert_eq!(x.to_string(), "My name is john and my age is 32".to_string());
}
```

</details>

> Note: You can redeclare the same inline struct in a different set, change the display message, and conversion between sets will still work.

### Feature Flags

**coerce_macro:** Each error set will generates a `coerce!` macro to help handle coercion between partially intersecting sets.
Expand Down

0 comments on commit 223f9a5

Please sign in to comment.