Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion swarm-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
let visibility = &ast.vis;

Some(quote! {
#visibility enum #name #impl_generics {
#visibility enum #name #impl_generics
#where_clause
{
#(#fields),*
}
})
Expand Down
15 changes: 14 additions & 1 deletion swarm-derive/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn custom_event_mismatching_field_names() {
}

#[test]
fn where_clause() {
fn bound() {
#[allow(dead_code)]
#[derive(NetworkBehaviour)]
struct Foo<T: Copy + NetworkBehaviour> {
Expand All @@ -281,6 +281,19 @@ fn where_clause() {
}
}

#[test]
fn where_clause() {
#[allow(dead_code)]
#[derive(NetworkBehaviour)]
struct Foo<T>
where
T: Copy + NetworkBehaviour,
{
ping: libp2p::ping::Ping,
bar: T,
}
}

#[test]
fn nested_derives_with_import() {
#[allow(dead_code)]
Expand Down