[pbs-devel] [PATCH proxmox 07/15] clippy fix: this (Default) `impl` can be derived

Lukas Wagner l.wagner at proxmox.com
Tue Aug 8 10:01:45 CEST 2023


Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 proxmox-api-macro/src/util.rs                 | 9 ++-------
 proxmox-subscription/src/subscription_info.rs | 9 +++------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs
index 1eba31f..b90f303 100644
--- a/proxmox-api-macro/src/util.rs
+++ b/proxmox-api-macro/src/util.rs
@@ -623,19 +623,14 @@ where
 }
 
 /// Helper to distinguish between explicitly set or derived data.
-#[derive(Clone, Copy, Eq, PartialEq)]
+#[derive(Clone, Copy, Default, Eq, PartialEq)]
 pub enum Maybe<T> {
     Explicit(T),
     Derived(T),
+    #[default]
     None,
 }
 
-impl<T> Default for Maybe<T> {
-    fn default() -> Self {
-        Maybe::None
-    }
-}
-
 impl<T> Maybe<T> {
     pub fn as_ref(&self) -> Maybe<&T> {
         match self {
diff --git a/proxmox-subscription/src/subscription_info.rs b/proxmox-subscription/src/subscription_info.rs
index 8c0bd3e..f455392 100644
--- a/proxmox-subscription/src/subscription_info.rs
+++ b/proxmox-subscription/src/subscription_info.rs
@@ -20,7 +20,7 @@ pub(crate) const SUBSCRIPTION_MAX_KEY_CHECK_FAILURE_AGE: i64 = 5 * 24 * 3600;
 
 // Aliases are needed for PVE compat!
 #[cfg_attr(feature = "api-types", api())]
-#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
+#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
 #[serde(rename_all = "lowercase")]
 /// Subscription status
 pub enum SubscriptionStatus {
@@ -29,6 +29,7 @@ pub enum SubscriptionStatus {
     #[serde(alias = "New")]
     New,
     /// no subscription set
+    #[default]
     #[serde(alias = "NotFound")]
     NotFound,
     /// subscription set and active
@@ -44,11 +45,7 @@ pub enum SubscriptionStatus {
     #[serde(alias = "Suspended")]
     Suspended,
 }
-impl Default for SubscriptionStatus {
-    fn default() -> Self {
-        SubscriptionStatus::NotFound
-    }
-}
+
 impl std::fmt::Display for SubscriptionStatus {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         match self {
-- 
2.39.2






More information about the pbs-devel mailing list