* [yew-devel] [PATCH yew-comp 1/3] tree wide: switch from `Into` to `From` implementations where possible
@ 2025-01-14 9:09 Shannon Sterz
2025-01-14 9:09 ` [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter Shannon Sterz
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 9:09 UTC (permalink / raw)
To: yew-devel
this is more flexible as a `From` implementation gives us an `Into`
implementation for free. fixes the clippy ling `from_over_into` [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/configuration/network_edit.rs | 6 +++---
src/configuration/network_view.rs | 6 +++---
src/rrd_graph_new.rs | 6 +++---
src/rrd_timeframe_selector.rs | 6 +++---
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/configuration/network_edit.rs b/src/configuration/network_edit.rs
index 84a9380..b97b86a 100644
--- a/src/configuration/network_edit.rs
+++ b/src/configuration/network_edit.rs
@@ -369,9 +369,9 @@ impl Component for ProxmoxNetworkEdit {
}
}
-impl Into<VNode> for NetworkEdit {
- fn into(self) -> VNode {
- let comp = VComp::new::<ProxmoxNetworkEdit>(Rc::new(self), None);
+impl From<NetworkEdit> for VNode {
+ fn from(val: NetworkEdit) -> Self {
+ let comp = VComp::new::<ProxmoxNetworkEdit>(Rc::new(val), None);
VNode::from(comp)
}
}
diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index cc2faae..fa9f985 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -319,9 +319,9 @@ impl LoadableComponent for ProxmoxNetworkView {
}
}
-impl Into<VNode> for NetworkView {
- fn into(self) -> VNode {
- let comp = VComp::new::<LoadableComponentMaster<ProxmoxNetworkView>>(Rc::new(self), None);
+impl From<NetworkView> for VNode {
+ fn from(val: NetworkView) -> Self {
+ let comp = VComp::new::<LoadableComponentMaster<ProxmoxNetworkView>>(Rc::new(val), None);
VNode::from(comp)
}
}
diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 21890a1..2c77a38 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -1030,9 +1030,9 @@ impl Component for PwtRRDGraph {
}
}
-impl Into<VNode> for RRDGraph {
- fn into(self) -> VNode {
- let comp = VComp::new::<PwtRRDGraph>(Rc::new(self), None);
+impl From<RRDGraph> for VNode {
+ fn from(val: RRDGraph) -> Self {
+ let comp = VComp::new::<PwtRRDGraph>(Rc::new(val), None);
VNode::from(comp)
}
}
diff --git a/src/rrd_timeframe_selector.rs b/src/rrd_timeframe_selector.rs
index a027046..d674f7c 100644
--- a/src/rrd_timeframe_selector.rs
+++ b/src/rrd_timeframe_selector.rs
@@ -233,9 +233,9 @@ impl Component for PwtRRDTimeframeSelector {
}
}
-impl Into<VNode> for RRDTimeframeSelector {
- fn into(self) -> VNode {
- let comp = VComp::new::<PwtRRDTimeframeSelector>(Rc::new(self), None);
+impl From<RRDTimeframeSelector> for VNode {
+ fn from(val: RRDTimeframeSelector) -> Self {
+ let comp = VComp::new::<PwtRRDTimeframeSelector>(Rc::new(val), None);
VNode::from(comp)
}
}
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter
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
2025-01-14 9:24 ` [yew-devel] applied: " 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:22 ` [yew-devel] applied: [PATCH yew-comp 1/3] tree wide: switch from `Into` to `From` implementations where possible Dietmar Maurer
2 siblings, 1 reply; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 9:09 UTC (permalink / raw)
To: yew-devel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] [PATCH yew-comp 3/3] apt package manager: use a `Box` for `Package` enum variant
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 ` [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter Shannon Sterz
@ 2025-01-14 9:09 ` 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
2 siblings, 1 reply; 6+ messages in thread
From: Shannon Sterz @ 2025-01-14 9:09 UTC (permalink / raw)
To: yew-devel
otherwise there is a large size difference between different enum
members. this fixes the clippy lint `large_enum_variant` [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/apt_package_manager.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/apt_package_manager.rs b/src/apt_package_manager.rs
index 18454ed..ae1cd01 100644
--- a/src/apt_package_manager.rs
+++ b/src/apt_package_manager.rs
@@ -68,7 +68,7 @@ struct OriginInfo {
enum TreeEntry {
Root(Key),
Origin(OriginInfo),
- Package(Key, APTUpdateInfo),
+ Package(Key, Box<APTUpdateInfo>),
}
impl ExtractPrimaryKey for TreeEntry {
@@ -119,7 +119,7 @@ fn update_list_to_tree(updates: &[APTUpdateInfo]) -> SlabTree<TreeEntry> {
for package in package_list.into_iter() {
origin_node.append(TreeEntry::Package(
Key::from(package.package.clone()),
- package,
+ Box::new(package),
));
}
}
--
2.39.5
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] applied: [PATCH yew-comp 1/3] tree wide: switch from `Into` to `From` implementations where possible
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 ` [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter Shannon Sterz
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:22 ` Dietmar Maurer
2 siblings, 0 replies; 6+ messages in thread
From: Dietmar Maurer @ 2025-01-14 9:22 UTC (permalink / raw)
To: Yew framework devel list at Proxmox, Shannon Sterz
applied
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] applied: [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter
2025-01-14 9:09 ` [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter Shannon Sterz
@ 2025-01-14 9:24 ` Dietmar Maurer
0 siblings, 0 replies; 6+ messages in thread
From: Dietmar Maurer @ 2025-01-14 9:24 UTC (permalink / raw)
To: Yew framework devel list at Proxmox, Shannon Sterz
applied
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [yew-devel] applied: [PATCH yew-comp 3/3] apt package manager: use a `Box` for `Package` enum variant
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 ` Dietmar Maurer
0 siblings, 0 replies; 6+ messages in thread
From: Dietmar Maurer @ 2025-01-14 9:24 UTC (permalink / raw)
To: Yew framework devel list at Proxmox, Shannon Sterz
applied
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-14 9:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [yew-devel] [PATCH yew-comp 2/3] tree wide: implement `Default` for `new()` functions without parameter Shannon Sterz
2025-01-14 9:24 ` [yew-devel] applied: " 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
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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal