mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-05 15:42:16 +00:00
Fix custom derive when using a where clause (#853)
When injecting the users where clause we need to ensure a comma is inserted between the users where clause and ours.
This commit is contained in:
parent
2b4d9786ac
commit
69abfbb18e
@ -112,7 +112,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
additional.push(quote!{#substream_generic: ::libp2p::tokio_io::AsyncWrite});
|
||||
|
||||
if let Some(where_clause) = where_clause {
|
||||
Some(quote!{#where_clause #(#additional),*})
|
||||
Some(quote!{#where_clause, #(#additional),*})
|
||||
} else {
|
||||
Some(quote!{where #(#additional),*})
|
||||
}
|
||||
|
@ -190,3 +190,24 @@ fn custom_event_and_polling() {
|
||||
require_net_behaviour::<Foo<TSubstream>>();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn where_clause() {
|
||||
#[allow(dead_code)]
|
||||
#[derive(NetworkBehaviour)]
|
||||
struct Foo<TSubstream> where TSubstream: std::fmt::Debug {
|
||||
ping: libp2p::ping::Ping<TSubstream>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(NetworkBehaviour)]
|
||||
struct Bar<TSubstream: std::fmt::Debug> {
|
||||
ping: libp2p::ping::Ping<TSubstream>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(NetworkBehaviour)]
|
||||
struct Qux<TSubstream: std::fmt::Debug> where TSubstream: Clone {
|
||||
ping: libp2p::ping::Ping<TSubstream>,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user