Skip to content

Commit 6a08cb1

Browse files
authored
Add information about trait_transformer to README
1 parent 445c29e commit 6a08cb1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
Utilities for working with impl traits in Rust.
44

5+
## `trait_transformer`
6+
7+
Trait transformer is an experimental crate that generates specialized versions of a base trait. For example, if you want a `Send`able version of your trait, you'd write:
8+
9+
```rust
10+
#[trait_transformer(SendIntFactory: Send)]
11+
trait IntFactory {
12+
async fn make(&self) -> i32;
13+
// ..or..
14+
fn stream(&self) -> impl Iterator<Item = i32>;
15+
fn call(&self) -> u32;
16+
}
17+
```
18+
19+
Which creates a new `SendIntFactory: IntFactory + Send` trait and additionally bounds `SendIntFactory::make(): Send` and `SendIntFactory::stream(): Send`. The generated sytax is still experimental, as it relies on the nightly and unstable `async_fn_in_trait`, `return_position_impl_trait_in_trait`, and `return_type_notation` features.
20+
521
#### License and usage notes
622

723
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or

0 commit comments

Comments
 (0)