From 7fe4459da1b0fed8eeb0f16f8f8e9a0bf8efb7a9 Mon Sep 17 00:00:00 2001 From: Integral Date: Sat, 2 Nov 2024 17:45:12 +0800 Subject: [PATCH] refactor: destruct tuples to enhance readability Signed-off-by: Integral --- src/cli/systemd_dbus.rs | 7 ++----- src/quadlet/container/mount/tmpfs.rs | 4 ++-- src/serde.rs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/cli/systemd_dbus.rs b/src/cli/systemd_dbus.rs index 9e16fd5..0971095 100644 --- a/src/cli/systemd_dbus.rs +++ b/src/cli/systemd_dbus.rs @@ -33,10 +33,7 @@ pub struct UnitFile { } impl From<(String, String)> for UnitFile { - fn from(value: (String, String)) -> Self { - Self { - file_name: value.0, - status: value.1, - } + fn from((file_name, status): (String, String)) -> Self { + Self { file_name, status } } } diff --git a/src/quadlet/container/mount/tmpfs.rs b/src/quadlet/container/mount/tmpfs.rs index 867ac49..84fb242 100644 --- a/src/quadlet/container/mount/tmpfs.rs +++ b/src/quadlet/container/mount/tmpfs.rs @@ -182,8 +182,8 @@ impl<'de> de::Visitor<'de> for Visitor { Field::Mode => { check_duplicate(&mode, Field::Mode)?; // serde(with = "mode") - let value: SerdeMode = map.next_value()?; - mode = Some(value.0); + let SerdeMode(value) = map.next_value()?; + mode = Some(value); } // tmpcopyup, notmpcopyup values (de)serialize as unit (i.e. no value) Field::TmpCopyUp => tmpcopyup = true, diff --git a/src/serde.rs b/src/serde.rs index b67fbb9..72943fd 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -81,7 +81,7 @@ where S: Serializer, { let iter = value.into_iter(); - let len = iter.size_hint().1; + let (_, len) = iter.size_hint(); let mut state = serializer.serialize_seq(len)?;