aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-20 09:54:46 +0100
committerMartin Fischer <martin@push-f.com>2021-11-20 10:19:03 +0100
commit80225095fe224285215b83406950d53835e4dcf9 (patch)
treea411628be8d25e402b91dae77bc92403c3604c6f
parent2eca6efb508f7603b8408534471248f956de5f7d (diff)
support where clauses for trait generics
-rw-r--r--src/lib.rs4
-rw-r--r--tests/tests.rs10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index abeab4c..b655778 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -338,10 +338,10 @@ fn generate_blanket_impl(
eq_token: None,
default: None,
}));
- let (_, type_gen, _where) = dyn_trait.generics.split_for_impl();
+ let (_, type_gen, where_clause) = dyn_trait.generics.split_for_impl();
let dyn_trait_name = &dyn_trait.ident;
quote! {
- impl #blanket_generics #dyn_trait_name #type_gen for #some_ident {
+ impl #blanket_generics #dyn_trait_name #type_gen for #some_ident #where_clause {
#(#method_impls)*
}
}
diff --git a/tests/tests.rs b/tests/tests.rs
index 652be48..3a14811 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -77,6 +77,16 @@ trait Foo<X> {
}
#[dynamize::dynamize]
+trait FooWithWhere<X>
+where
+ X: std::fmt::Display,
+{
+ type A: Into<String>;
+
+ fn foobar(&self, x: X) -> Self::A;
+}
+
+#[dynamize::dynamize]
trait Bar<X> {
fn foobar<A>(&self, x: X) -> A;
}