From a6470f13c935502253038196f074b0405d1b60dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 3 Oct 2023 17:44:12 +0300 Subject: [PATCH] Fix various new 1.73 clippy warnings Part-of: --- gstreamer-audio/src/audio_converter.rs | 2 +- gstreamer-audio/src/audio_format.rs | 5 +++-- gstreamer-video/src/video_format.rs | 5 +++-- gstreamer-video/src/video_time_code.rs | 2 +- gstreamer/src/enums.rs | 4 ++-- gstreamer/src/pad.rs | 1 - gstreamer/src/subclass/task_pool.rs | 2 +- gstreamer/src/task.rs | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gstreamer-audio/src/audio_converter.rs b/gstreamer-audio/src/audio_converter.rs index a2a1279e8..247e9070e 100644 --- a/gstreamer-audio/src/audio_converter.rs +++ b/gstreamer-audio/src/audio_converter.rs @@ -160,7 +160,7 @@ impl AudioConverterConfig { }) .collect::>() }) - .unwrap_or_else(Vec::new) + .unwrap_or_default() } #[cfg(feature = "v1_22")] diff --git a/gstreamer-audio/src/audio_format.rs b/gstreamer-audio/src/audio_format.rs index 92e9aedb9..efc3718a6 100644 --- a/gstreamer-audio/src/audio_format.rs +++ b/gstreamer-audio/src/audio_format.rs @@ -148,13 +148,14 @@ impl str::FromStr for crate::AudioFormat { } impl PartialOrd for crate::AudioFormat { + #[inline] fn partial_cmp(&self, other: &Self) -> Option { - crate::AudioFormatInfo::from_format(*self) - .partial_cmp(&crate::AudioFormatInfo::from_format(*other)) + Some(self.cmp(other)) } } impl Ord for crate::AudioFormat { + #[inline] fn cmp(&self, other: &Self) -> std::cmp::Ordering { crate::AudioFormatInfo::from_format(*self).cmp(&crate::AudioFormatInfo::from_format(*other)) } diff --git a/gstreamer-video/src/video_format.rs b/gstreamer-video/src/video_format.rs index 4e8518c81..0c21dffc5 100644 --- a/gstreamer-video/src/video_format.rs +++ b/gstreamer-video/src/video_format.rs @@ -305,13 +305,14 @@ impl str::FromStr for crate::VideoFormat { } impl PartialOrd for crate::VideoFormat { + #[inline] fn partial_cmp(&self, other: &Self) -> Option { - crate::VideoFormatInfo::from_format(*self) - .partial_cmp(&crate::VideoFormatInfo::from_format(*other)) + Some(self.cmp(other)) } } impl Ord for crate::VideoFormat { + #[inline] fn cmp(&self, other: &Self) -> std::cmp::Ordering { crate::VideoFormatInfo::from_format(*self).cmp(&crate::VideoFormatInfo::from_format(*other)) } diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index 2ded8ddaf..ca8876f3a 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -461,7 +461,7 @@ impl Eq for ValidVideoTimeCode {} impl PartialOrd for ValidVideoTimeCode { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - self.compare(other).partial_cmp(&0) + Some(self.cmp(other)) } } diff --git a/gstreamer/src/enums.rs b/gstreamer/src/enums.rs index a5050019f..dbbcedd1f 100644 --- a/gstreamer/src/enums.rs +++ b/gstreamer/src/enums.rs @@ -483,7 +483,7 @@ impl Eq for crate::TypeFindProbability {} impl PartialOrd for crate::TypeFindProbability { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - (self.into_glib() as u32).partial_cmp(&(other.into_glib() as u32)) + Some(self.cmp(other)) } } @@ -542,7 +542,7 @@ impl Eq for crate::Rank {} impl PartialOrd for crate::Rank { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - (self.into_glib() as u32).partial_cmp(&(other.into_glib() as u32)) + Some(self.cmp(other)) } } diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 195cc826f..8028bf356 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -2047,7 +2047,6 @@ mod tests { { let buffers = buffers.clone(); - let flow_override = flow_override; pad.add_probe(crate::PadProbeType::BUFFER, move |_, info| { if let Some(PadProbeData::Buffer(buffer)) = info.data.take() { let mut buffers = buffers.lock().unwrap(); diff --git a/gstreamer/src/subclass/task_pool.rs b/gstreamer/src/subclass/task_pool.rs index 734ba9b5d..bfc0b59c2 100644 --- a/gstreamer/src/subclass/task_pool.rs +++ b/gstreamer/src/subclass/task_pool.rs @@ -215,7 +215,7 @@ impl Eq for TaskPoolFunction {} impl PartialOrd for TaskPoolFunction { fn partial_cmp(&self, other: &Self) -> Option { - self.as_ptr().partial_cmp(&other.as_ptr()) + Some(self.cmp(other)) } } diff --git a/gstreamer/src/task.rs b/gstreamer/src/task.rs index c9746b40a..ce56a1c9f 100644 --- a/gstreamer/src/task.rs +++ b/gstreamer/src/task.rs @@ -80,7 +80,7 @@ impl TaskBuilder { (*func_ptr).1 = task.to_glib_none().0; - let lock = self.lock.unwrap_or_else(TaskLock::new); + let lock = self.lock.unwrap_or_default(); ffi::gst_task_set_lock(task.to_glib_none().0, mut_override(&lock.0 .0)); task.set_data("gstreamer-rs-task-lock", Arc::clone(&lock.0));