From b8cf46abf02e54900ca5c514da168033b6cdfc1b Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Thu, 28 Nov 2024 09:51:31 +0100 Subject: [PATCH] fix clippy issues --- examples/basic/src/main.rs | 4 ++-- waku-bindings/src/node/context.rs | 10 +++++----- waku-bindings/src/node/filter.rs | 6 ++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index fc9fbf6..f7b9a1d 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -24,7 +24,7 @@ async fn main() -> Result<(), Error> { // ======================================================================== // Setting an event callback to be executed each time a message is received node2 - .set_event_callback(&|response| { + .set_event_callback(|response| { if let LibwakuResponse::Success(v) = response { let event: Event = serde_json::from_str(v.unwrap().as_str()).expect("Parsing event to succeed"); @@ -47,7 +47,7 @@ async fn main() -> Result<(), Error> { .expect("set event call back working"); node1 - .set_event_callback(&|response| { + .set_event_callback(|response| { if let LibwakuResponse::Success(v) = response { let event: Event = serde_json::from_str(v.unwrap().as_str()).expect("Parsing event to succeed"); diff --git a/waku-bindings/src/node/context.rs b/waku-bindings/src/node/context.rs index a9cbd1a..5305a4a 100644 --- a/waku-bindings/src/node/context.rs +++ b/waku-bindings/src/node/context.rs @@ -4,15 +4,17 @@ use std::sync::{Arc, Mutex}; use crate::utils::{get_trampoline, LibwakuResponse}; +type LibwakuResponseClosure = dyn FnMut(LibwakuResponse) + Send + Sync; + pub struct WakuNodeContext { obj_ptr: *mut c_void, - msg_observer: Arc>>, + msg_observer: Arc>>, } impl WakuNodeContext { pub fn new(obj_ptr: *mut c_void) -> Self { let me = Self { - obj_ptr: obj_ptr, + obj_ptr, msg_observer: Arc::new(Mutex::new(Box::new(|_| {}))), }; @@ -54,9 +56,7 @@ impl WakuNodeContext { }; Ok(()) } else { - Err(format!( - "Failed to acquire lock in waku_set_event_callback!" - )) + Err("Failed to acquire lock in waku_set_event_callback!".to_string()) } } } diff --git a/waku-bindings/src/node/filter.rs b/waku-bindings/src/node/filter.rs index 2dd599f..9bf0208 100644 --- a/waku-bindings/src/node/filter.rs +++ b/waku-bindings/src/node/filter.rs @@ -89,13 +89,11 @@ pub fn waku_filter_unsubscribe_all(ctx: &WakuNodeContext) -> Result<()> { let code = unsafe { let mut closure = result_cb; let cb = get_trampoline(&closure); - let out = waku_sys::waku_filter_unsubscribe_all( + waku_sys::waku_filter_unsubscribe_all( ctx.get_ptr(), cb, &mut closure as *mut _ as *mut c_void, - ); - - out + ) }; handle_no_response(code, result)