mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-17 20:11:22 +00:00
derive(NetworkBehaviour) handles trailing commas (#874)
Properly handle trailing commas in derive(NetworkBehaviour)
This commit is contained in:
committed by
Pierre Krieger
parent
6d24596f9f
commit
615dd3332f
@ -112,7 +112,11 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
|||||||
additional.push(quote!{#substream_generic: ::libp2p::tokio_io::AsyncWrite});
|
additional.push(quote!{#substream_generic: ::libp2p::tokio_io::AsyncWrite});
|
||||||
|
|
||||||
if let Some(where_clause) = where_clause {
|
if let Some(where_clause) = where_clause {
|
||||||
|
if where_clause.predicates.trailing_punct() {
|
||||||
|
Some(quote!{#where_clause #(#additional),*})
|
||||||
|
} else {
|
||||||
Some(quote!{#where_clause, #(#additional),*})
|
Some(quote!{#where_clause, #(#additional),*})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Some(quote!{where #(#additional),*})
|
Some(quote!{where #(#additional),*})
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,12 @@ fn where_clause() {
|
|||||||
ping: libp2p::ping::Ping<TSubstream>,
|
ping: libp2p::ping::Ping<TSubstream>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(NetworkBehaviour)]
|
||||||
|
struct Baz<TSubstream> where TSubstream: std::fmt::Debug + Clone, {
|
||||||
|
ping: libp2p::ping::Ping<TSubstream>,
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(NetworkBehaviour)]
|
#[derive(NetworkBehaviour)]
|
||||||
struct Qux<TSubstream: std::fmt::Debug> where TSubstream: Clone {
|
struct Qux<TSubstream: std::fmt::Debug> where TSubstream: Clone {
|
||||||
|
Reference in New Issue
Block a user