From f8b49fc1bef7f08e53c87a4bf95a128fce38abb9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 22 Sep 2022 10:00:33 +0200 Subject: [PATCH] clippy fixups Signed-off-by: Wolfgang Bumiller --- perlmod-macro/src/function.rs | 2 +- perlmod/src/scalar.rs | 2 +- perlmod/src/ser.rs | 2 +- perlmod/src/value.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/perlmod-macro/src/function.rs b/perlmod-macro/src/function.rs index c24035d..9e982c2 100644 --- a/perlmod-macro/src/function.rs +++ b/perlmod-macro/src/function.rs @@ -78,7 +78,7 @@ pub fn handle_function( } let name = func.sig.ident.clone(); - let export_public = export_public.then(|| &func.vis); + let export_public = export_public.then_some(&func.vis); let xs_name = attr .xs_name .clone() diff --git a/perlmod/src/scalar.rs b/perlmod/src/scalar.rs index ed13b34..0a7ca00 100644 --- a/perlmod/src/scalar.rs +++ b/perlmod/src/scalar.rs @@ -413,7 +413,7 @@ impl ScalarRef { /// If `blessed` is true and the value is a blessed reference, the package name will be /// returned, otherwise the scalar type (`"SCALAR"`, `"ARRAY"`, ...) will be returned. pub fn reftype(&self, blessed: bool) -> &'static str { - let ptr = unsafe { ffi::RSPL_sv_reftype(self.sv(), if blessed { 1 } else { 0 }) }; + let ptr = unsafe { ffi::RSPL_sv_reftype(self.sv(), i32::from(blessed)) }; if ptr.is_null() { "" diff --git a/perlmod/src/ser.rs b/perlmod/src/ser.rs index 17f0bca..9561615 100644 --- a/perlmod/src/ser.rs +++ b/perlmod/src/ser.rs @@ -64,7 +64,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { type SerializeStructVariant = SerVariant; fn serialize_bool(self, v: bool) -> Result { - Ok(Value::new_uint(if v { 1 } else { 0 })) + Ok(Value::new_uint(usize::from(v))) } fn serialize_i8(self, v: i8) -> Result { diff --git a/perlmod/src/value.rs b/perlmod/src/value.rs index 89edfc1..b320b0c 100644 --- a/perlmod/src/value.rs +++ b/perlmod/src/value.rs @@ -527,7 +527,7 @@ impl<'de> Deserialize<'de> for Value { #[inline] fn visit_bool(self, value: bool) -> Result { - Ok(Value::new_int(if value { 1 } else { 0 })) + Ok(Value::new_int(isize::from(value))) } #[inline]