add poll parameters to custom poll function (#1442)

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
vms 2020-02-13 13:17:55 +03:00 committed by GitHub
parent cdb733b479
commit e2ddab223d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -371,7 +371,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
syn::NestedMeta::Meta(syn::Meta::NameValue(ref m)) if m.path.is_ident("poll_method") => { syn::NestedMeta::Meta(syn::Meta::NameValue(ref m)) if m.path.is_ident("poll_method") => {
if let syn::Lit::Str(ref s) = m.lit { if let syn::Lit::Str(ref s) = m.lit {
let ident: Ident = syn::parse_str(&s.value()).unwrap(); let ident: Ident = syn::parse_str(&s.value()).unwrap();
poll_method = quote!{#name::#ident(self, cx)}; poll_method = quote!{#name::#ident(self, cx, poll_params)};
} }
} }
_ => () _ => ()

View File

@ -130,7 +130,7 @@ fn custom_polling() {
} }
impl Foo { impl Foo {
fn foo<T>(&mut self, _: &mut std::task::Context) -> std::task::Poll<libp2p::swarm::NetworkBehaviourAction<T, ()>> { std::task::Poll::Pending } fn foo<T>(&mut self, _: &mut std::task::Context, _: &mut impl libp2p::swarm::PollParameters) -> std::task::Poll<libp2p::swarm::NetworkBehaviourAction<T, ()>> { std::task::Poll::Pending }
} }
#[allow(dead_code)] #[allow(dead_code)]
@ -186,7 +186,7 @@ fn custom_event_and_polling() {
} }
impl Foo { impl Foo {
fn foo<T>(&mut self, _: &mut std::task::Context) -> std::task::Poll<libp2p::swarm::NetworkBehaviourAction<T, String>> { std::task::Poll::Pending } fn foo<T>(&mut self, _: &mut std::task::Context, _: &mut impl libp2p::swarm::PollParameters) -> std::task::Poll<libp2p::swarm::NetworkBehaviourAction<T, String>> { std::task::Poll::Pending }
} }
#[allow(dead_code)] #[allow(dead_code)]