Skip to content

Commit a79f1d8

Browse files
authored
Merge splitting off of trait-transformer crate
This is PR #9.
2 parents 9deed11 + 1c75be2 commit a79f1d8

File tree

9 files changed

+62
-14
lines changed

9 files changed

+62
-14
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
members = [
33
"trait-variant",
4+
"trait-transformer",
45
]
56

67
resolver = "2"

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ Which creates a new `SendIntFactory: IntFactory + Send` trait and additionally b
2020

2121
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.
2222

23-
## `trait_transformer`
24-
25-
`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.
26-
2723
#### License and usage notes
2824

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

trait-transformer/Cargo.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6+
# option. This file may not be copied, modified, or distributed
7+
# except according to those terms.
8+
9+
[package]
10+
name = "trait-transformer"
11+
version = "0.0.0"
12+
description = "Utilities for working with impl traits in Rust"
13+
categories = ["asynchronous", "no-std", "rust-patterns"]
14+
keywords = ["async", "trait", "impl"]
15+
license.workspace = true
16+
repository.workspace = true
17+
edition = "2021"
18+
19+
[lib]
20+
proc-macro = true
21+
22+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
23+
24+
[dependencies]
25+
proc-macro2 = "1.0"
26+
quote = "1.0"
27+
syn = { version = "2.0", features = ["full"] }
28+
29+
[dev-dependencies]
30+
tokio = { version = "1", features = ["rt"] }

trait-transformer/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## `trait_transformer`
2+
3+
`trait_transformer` does the same thing as `trait_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-variant/examples/trait_transformer.rs renamed to trait-transformer/examples/trait_transformer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use std::iter;
1313

14-
use trait_variant::trait_transformer;
14+
use trait_transformer::trait_transformer;
1515

1616
#[trait_transformer(SendIntFactory: Send)]
1717
trait IntFactory {

trait-transformer/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6+
// option. This file may not be copied, modified, or distributed
7+
// except according to those terms.
8+
9+
mod transformer;
10+
11+
#[proc_macro_attribute]
12+
pub fn trait_transformer(
13+
attr: proc_macro::TokenStream,
14+
item: proc_macro::TokenStream,
15+
) -> proc_macro::TokenStream {
16+
transformer::trait_transformer(attr, item)
17+
}

trait-variant/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@
88

99
#![doc = include_str!("../README.md")]
1010

11-
mod transformer;
1211
mod variant;
1312

14-
#[proc_macro_attribute]
15-
pub fn trait_transformer(
16-
attr: proc_macro::TokenStream,
17-
item: proc_macro::TokenStream,
18-
) -> proc_macro::TokenStream {
19-
transformer::trait_transformer(attr, item)
20-
}
21-
2213
#[proc_macro_attribute]
2314
pub fn make(
2415
attr: proc_macro::TokenStream,

0 commit comments

Comments
 (0)