From 2c7980b773cad586af5db8ff0755f1d74d94f7d1 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 14 Oct 2024 18:05:33 +0200 Subject: refactor(treewide): Conform to the clippy and rust lints --- crates/libmpv2/libmpv2-sys/src/lib.rs | 9 +++++---- crates/libmpv2/src/mpv.rs | 4 +++- crates/libmpv2/src/mpv/protocol.rs | 2 +- crates/libmpv2/src/mpv/render.rs | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'crates/libmpv2') diff --git a/crates/libmpv2/libmpv2-sys/src/lib.rs b/crates/libmpv2/libmpv2-sys/src/lib.rs index 36a8199..0d14dbb 100644 --- a/crates/libmpv2/libmpv2-sys/src/lib.rs +++ b/crates/libmpv2/libmpv2-sys/src/lib.rs @@ -1,7 +1,3 @@ -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - // yt - A fully featured command line YouTube client // // Copyright (C) 2024 Benedikt Peetz @@ -11,6 +7,11 @@ // // You should have received a copy of the License along with this program. // If not, see . +// +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(clippy::doc_lazy_continuation)] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/crates/libmpv2/src/mpv.rs b/crates/libmpv2/src/mpv.rs index 9d554a6..bf4581e 100644 --- a/crates/libmpv2/src/mpv.rs +++ b/crates/libmpv2/src/mpv.rs @@ -51,6 +51,7 @@ fn mpv_err(ret: T, err: ctype::c_int) -> Result { } /// This trait describes which types are allowed to be passed to getter mpv APIs. +#[allow(clippy::missing_safety_doc)] pub unsafe trait GetData: Sized { #[doc(hidden)] fn get_from_c_void Result>(mut fun: F) -> Result { @@ -62,6 +63,7 @@ pub unsafe trait GetData: Sized { } /// This trait describes which types are allowed to be passed to setter mpv APIs. +#[allow(clippy::missing_safety_doc)] pub unsafe trait SetData: Sized { #[doc(hidden)] fn call_as_c_void Result>( @@ -207,7 +209,7 @@ pub mod mpv_node { } } - pub fn child(self: Self, node: libmpv2_sys::mpv_node) -> Self { + pub fn child(self, node: libmpv2_sys::mpv_node) -> Self { Self { parent: self.parent, node, diff --git a/crates/libmpv2/src/mpv/protocol.rs b/crates/libmpv2/src/mpv/protocol.rs index 4ae4f16..31a5933 100644 --- a/crates/libmpv2/src/mpv/protocol.rs +++ b/crates/libmpv2/src/mpv/protocol.rs @@ -155,7 +155,7 @@ where { let data = Box::from_raw(cookie as *mut ProtocolData); - panic::catch_unwind(|| ((*data).close_fn)(Box::from_raw((*data).cookie))); + panic::catch_unwind(|| (data.close_fn)(Box::from_raw(data.cookie))); } struct ProtocolData { diff --git a/crates/libmpv2/src/mpv/render.rs b/crates/libmpv2/src/mpv/render.rs index 91db34e..c3f2dc9 100644 --- a/crates/libmpv2/src/mpv/render.rs +++ b/crates/libmpv2/src/mpv/render.rs @@ -213,8 +213,8 @@ impl RenderContext { params: impl IntoIterator>, ) -> Result { let params: Vec<_> = params.into_iter().collect(); - let mut raw_params: Vec = Vec::new(); - raw_params.reserve(params.len() + 1); + let mut raw_params: Vec = + Vec::with_capacity(params.len() + 1); let mut raw_ptrs: HashMap<*const c_void, DeleterFn> = HashMap::new(); for p in params { -- cgit 1.4.1