From 3f969485b7bc7ac71278302cf36d83ec27d7769d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Wed, 6 Nov 2024 16:01:39 +0100 Subject: [PATCH] gst: BufferList::foreach{_mut} discard bool result If we really wanted to return a value, we would use `ControlFlow`. In Rust, if we need to inform the caller that processing has stopped, we'd rather do this by updating a variable from within the `func`. Part-of: --- gstreamer/src/bufferlist.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index e96e388a7..d5949dd88 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -136,7 +136,7 @@ impl BufferListRef { } #[doc(alias = "gst_buffer_list_foreach")] - pub fn foreach ControlFlow<(), ()>>(&self, func: F) -> bool { + pub fn foreach ControlFlow<(), ()>>(&self, func: F) { unsafe extern "C" fn trampoline ControlFlow<(), ()>>( buffer: *mut *mut ffi::GstBuffer, idx: u32, @@ -152,11 +152,11 @@ impl BufferListRef { let mut func = func; let func_ptr: &mut F = &mut func; - from_glib(ffi::gst_buffer_list_foreach( + let _ = ffi::gst_buffer_list_foreach( self.as_ptr() as *mut _, Some(trampoline::), func_ptr as *mut _ as *mut _, - )) + ); } } @@ -164,7 +164,7 @@ impl BufferListRef { pub fn foreach_mut ControlFlow, Option>>( &mut self, func: F, - ) -> bool { + ) { unsafe extern "C" fn trampoline< F: FnMut(Buffer, usize) -> ControlFlow, Option>, >( @@ -202,11 +202,11 @@ impl BufferListRef { let mut func = func; let func_ptr: &mut F = &mut func; - from_glib(ffi::gst_buffer_list_foreach( + let _ = ffi::gst_buffer_list_foreach( self.as_ptr() as *mut _, Some(trampoline::), func_ptr as *mut _ as *mut _, - )) + ); } } }