From 25175bfbb5ff1b26f6d796f9fc535b964a67aab2 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Thu, 12 Oct 2023 12:00:42 +0200 Subject: [PATCH] Use match instead of if-else to unpack ptr from Option This silences a warning on nightly rustc --- src/backend/resampler.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/backend/resampler.rs b/src/backend/resampler.rs index fb5b0e9e..b72fc631 100644 --- a/src/backend/resampler.rs +++ b/src/backend/resampler.rs @@ -19,15 +19,13 @@ impl Resampler { reclock: ffi::cubeb_resampler_reclock, ) -> Self { let raw_resampler = unsafe { - let in_params = if input_params.is_some() { - input_params.as_mut().unwrap() as *mut ffi::cubeb_stream_params - } else { - ptr::null_mut() + let in_params = match &mut input_params { + Some(p) => p, + None => ptr::null_mut(), }; - let out_params = if output_params.is_some() { - output_params.as_mut().unwrap() as *mut ffi::cubeb_stream_params - } else { - ptr::null_mut() + let out_params = match &mut output_params { + Some(p) => p, + None => ptr::null_mut(), }; ffi::cubeb_resampler_create( stream,