From: Lukas Wagner <l.wagner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 07/15] clippy fix: this (Default) `impl` can be derived
Date: Tue, 8 Aug 2023 10:01:45 +0200 [thread overview]
Message-ID: <20230808080153.79587-7-l.wagner@proxmox.com> (raw)
In-Reply-To: <20230808080153.79587-1-l.wagner@proxmox.com>
Signed-off-by: Lukas Wagner <l.wagner@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
next prev parent reply other threads:[~2023-08-08 8:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 8:01 [pbs-devel] [PATCH proxmox 01/15] clippy fix: the borrowed expression implements the required traits Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 02/15] clippy fix: casting to the same type is unnecessary Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 03/15] clippy fix: calls to `drop` with a value that implements `Copy` Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 04/15] clippy fix: needless borrow Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 05/15] clippy fix: unneeded `return` statement Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 06/15] clippy fix: redundant closure Lukas Wagner
2023-08-08 8:01 ` Lukas Wagner [this message]
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 08/15] clippy fix: you should consider adding a `Default` implementation Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 09/15] clippy fix: unnecessary use of `to_string` Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 10/15] clippy fix: binary comparison to literal `Option::None` Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 11/15] clippy fix: warning: this let-binding has unit value Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 12/15] clippy fix: useless use of `format!` Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 13/15] clippy fix: the following explicit lifetimes could be elided Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 14/15] clippy fix: complex type definitions Lukas Wagner
2023-08-08 8:01 ` [pbs-devel] [PATCH proxmox 15/15] clippy fix: deref on an immutable reference Lukas Wagner
2023-08-08 9:33 ` [pbs-devel] partially-applied: [PATCH proxmox 01/15] clippy fix: the borrowed expression implements the required traits Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230808080153.79587-7-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.