Skip to content

Commit ce9f579

Browse files
committed
Update README
1 parent 8bfd6e6 commit ce9f579

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# `impl_trait_utils`
1+
# impl-trait-utils
22

33
Utilities for working with impl traits in Rust.
44

5-
## `trait_transformer`
5+
## `make_variant`
66

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:
7+
`make_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:
88

99
```rust
10-
#[trait_transformer(SendIntFactory: Send)]
10+
#[trait_transformer::make_variant(SendIntFactory: Send)]
1111
trait IntFactory {
1212
async fn make(&self) -> i32;
1313
// ..or..
@@ -16,7 +16,13 @@ trait IntFactory {
1616
}
1717
```
1818

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.
19+
Which creates a new `SendIntFactory: IntFactory + Send` trait and additionally bounds `SendIntFactory::make(): Send` and `SendIntFactory::stream(): Send`. Ordinary methods are not affected.
20+
21+
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.
22+
23+
## `trait_transformer`
24+
25+
`trait_transformer` does the same thing as `make_variant`, but using experimental nightly-only syntax that depends on the `return_type_notation` feature. It may be used to experiment with new kinds of trait transformations in the future.
2026

2127
#### License and usage notes
2228

trait_transformer/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
#![doc = include_str!("../../README.md")]
10+
911
mod transformer;
1012
mod variant;
1113

0 commit comments

Comments
 (0)