Skip to content

Commit

Permalink
Merge clarifications to README
Browse files Browse the repository at this point in the history
This is PR #10.
  • Loading branch information
traviscross authored Dec 18, 2023
2 parents a79f1d8 + ecf92b3 commit 631ddf7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Utilities for working with impl traits in Rust.
`trait_variant` generates a specialized version of a base trait that uses `async fn` and/or `-> impl Trait`. For example, if you want a `Send`able version of your trait, you'd write:

```rust
#[trait_variant::make(SendIntFactory: Send)]
trait IntFactory {
#[trait_variant::make(IntFactory: Send)]
trait LocalIntFactory {
async fn make(&self) -> i32;
// ..or..
fn stream(&self) -> impl Iterator<Item = i32>;
fn call(&self) -> u32;
}
```

Which creates a new `SendIntFactory: IntFactory + Send` trait and additionally bounds `SendIntFactory::make(): Send` and `SendIntFactory::stream(): Send`. Ordinary methods are not affected.
Which creates a new `IntFactory: Send` trait and additionally bounds `IntFactory::make(): Send` and `IntFactory::stream(): Send`. Ordinary methods are not affected.

Implementers of the trait can choose to implement the variant instead of the original trait. The macro creates a blanket impl which ensures that any type which implements the variant also implements the original trait.

Expand Down

0 comments on commit 631ddf7

Please sign in to comment.