public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter
Date: Tue, 14 Jan 2025 10:09:39 +0100	[thread overview]
Message-ID: <20250114090940.29366-2-s.sterz@proxmox.com> (raw)
In-Reply-To: <20250114090940.29366-1-s.sterz@proxmox.com>

this allows usage of functions like `unwrap_or_default` for these
types and fixes the clippy lint `new_without_default`.

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
 src/apt_package_manager.rs        | 6 ++++++
 src/apt_repositories.rs           | 6 ++++++
 src/configuration/network_view.rs | 6 ++++++
 src/rrd_timeframe_selector.rs     | 6 ++++++
 4 files changed, 24 insertions(+)

diff --git a/src/apt_package_manager.rs b/src/apt_package_manager.rs
index 11d7eb8..18454ed 100644
--- a/src/apt_package_manager.rs
+++ b/src/apt_package_manager.rs
@@ -46,6 +46,12 @@ pub struct AptPackageManager {
     pub enable_upgrade: bool,
 }
 
+impl Default for AptPackageManager {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl AptPackageManager {
     pub fn new() -> Self {
         yew::props!(Self {})
diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index 7149545..b671d01e 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -49,6 +49,12 @@ pub struct AptRepositories {
     pub product: Option<ExistingProduct>,
 }
 
+impl Default for AptRepositories {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl AptRepositories {
     pub fn new() -> Self {
         yew::props!(Self {})
diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index fa9f985..d7d519c 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -52,6 +52,12 @@ async fn apply_changes() -> Result<String, Error> {
 #[derive(PartialEq, Properties)]
 pub struct NetworkView {}
 
+impl Default for NetworkView {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl NetworkView {
     pub fn new() -> Self {
         Self {}
diff --git a/src/rrd_timeframe_selector.rs b/src/rrd_timeframe_selector.rs
index d674f7c..5758a04 100644
--- a/src/rrd_timeframe_selector.rs
+++ b/src/rrd_timeframe_selector.rs
@@ -28,6 +28,12 @@ pub struct RRDTimeframeSelector {
     on_change: Option<Callback<RRDTimeframe>>,
 }
 
+impl Default for RRDTimeframeSelector {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl RRDTimeframeSelector {
     pub fn new() -> Self {
         yew::props!(Self {})
-- 
2.39.5



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


  reply	other threads:[~2025-01-14  9:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  9:09 [yew-devel] [PATCH yew-comp 1/3] tree wide: switch from `Into` to `From` implementations where possible Shannon Sterz
2025-01-14  9:09 ` Shannon Sterz [this message]
2025-01-14  9:24   ` [yew-devel] applied: [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter Dietmar Maurer
2025-01-14  9:09 ` [yew-devel] [PATCH yew-comp 3/3] apt package manager: use a `Box` for `Package` enum variant Shannon Sterz
2025-01-14  9:24   ` [yew-devel] applied: " Dietmar Maurer
2025-01-14  9:22 ` [yew-devel] applied: [PATCH yew-comp 1/3] tree wide: switch from `Into` to `From` implementations where possible Dietmar Maurer

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=20250114090940.29366-2-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=yew-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal