Skip to content

Commit

Permalink
Merge shortening of name to trait_variant::make
Browse files Browse the repository at this point in the history
This is PR #8.
  • Loading branch information
traviscross authored Dec 18, 2023
2 parents a4ced57 + 956123d commit 9deed11
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

Utilities for working with impl traits in Rust.

## `make_variant`
## `trait_variant`

`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:
`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_variant(SendIntFactory: Send)]
#[trait_variant::make(SendIntFactory: Send)]
trait IntFactory {
async fn make(&self) -> i32;
// ..or..
Expand All @@ -22,7 +22,7 @@ Implementers of the trait can choose to implement the variant instead of the ori

## `trait_transformer`

`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.
`trait_transformer` does the same thing as `make`, 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.

#### License and usage notes

Expand Down
4 changes: 1 addition & 3 deletions trait-variant/examples/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

use std::future::Future;

use trait_variant::make_variant;

#[make_variant(IntFactory: Send)]
#[trait_variant::make(IntFactory: Send)]
pub trait LocalIntFactory {
const NAME: &'static str;

Expand Down
4 changes: 2 additions & 2 deletions trait-variant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub fn trait_transformer(
}

#[proc_macro_attribute]
pub fn make_variant(
pub fn make(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
variant::make_variant(attr, item)
variant::make(attr, item)
}
2 changes: 1 addition & 1 deletion trait-variant/src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Parse for MakeVariant {
}
}

pub fn make_variant(
pub fn make(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
Expand Down

0 comments on commit 9deed11

Please sign in to comment.