Skip to content

Commit 64c4b63

Browse files
committed
Upgrade implicit-clone to 0.4.7 and use derive macro when possible
1 parent 25f3494 commit 64c4b63

File tree

15 files changed

+31
-61
lines changed

15 files changed

+31
-61
lines changed

Cargo.lock

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/nested_list/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ impl<COMP: Component> PartialEq for WeakComponentLink<COMP> {
4040
}
4141
}
4242

43-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
43+
#[derive(Debug, Clone, ImplicitClone, PartialEq, Eq, Hash)]
4444
pub enum Hovered {
4545
Header,
4646
Item(AttrValue),
4747
List,
4848
None,
4949
}
5050

51-
impl ImplicitClone for Hovered {}
52-
5351
impl fmt::Display for Hovered {
5452
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5553
write!(

packages/yew-macro/tests/html_macro/component-pass.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ impl ::yew::Component for Container {
6161
}
6262
}
6363

64-
#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
64+
#[derive(::std::clone::Clone, ::yew::html::ImplicitClone, ::std::cmp::PartialEq)]
6565
pub enum ChildrenVariants {
6666
Child(::yew::virtual_dom::VChild<Child>),
6767
AltChild(::yew::virtual_dom::VChild<AltChild>),
6868
}
6969

70-
impl ::yew::html::ImplicitClone for ChildrenVariants {}
71-
7270
impl ::std::convert::From<::yew::virtual_dom::VChild<Child>> for ChildrenVariants {
7371
fn from(comp: ::yew::virtual_dom::VChild<Child>) -> Self {
7472
ChildrenVariants::Child(comp)

packages/yew/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ yew-macro = { version = "^0.21.0", path = "../yew-macro" }
2727
thiserror = "1.0"
2828
futures = { version = "0.3", default-features = false, features = ["std"] }
2929
html-escape = { version = "0.2.13", optional = true }
30-
implicit-clone = { version = "0.4.5", features = ["map"] }
30+
implicit-clone = { version = "0.4.7", features = ["map"] }
3131
base64ct = { version = "1.6.0", features = ["std"], optional = true }
3232
bincode = { version = "1.3.3", optional = true }
3333
serde = { version = "1", features = ["derive"] }

packages/yew/src/html/classes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ use std::borrow::Cow;
22
use std::iter::FromIterator;
33
use std::rc::Rc;
44

5-
use implicit_clone::ImplicitClone;
65
use indexmap::IndexSet;
76

87
use super::IntoPropValue;
8+
use crate::html::ImplicitClone;
99
use crate::utils::RcExt;
1010
use crate::virtual_dom::AttrValue;
1111

1212
/// A set of classes, cheap to clone.
1313
///
1414
/// The preferred way of creating this is using the [`classes!`][yew::classes!] macro.
15-
#[derive(Debug, Clone, Default)]
15+
#[derive(Debug, Clone, ImplicitClone, Default)]
1616
pub struct Classes {
1717
set: Rc<IndexSet<AttrValue>>,
1818
}
1919

20-
impl ImplicitClone for Classes {}
21-
2220
/// helper method to efficiently turn a set of classes into a space-separated
2321
/// string. Abstracts differences between ToString and IntoPropValue. The
2422
/// `rest` iterator is cloned to pre-compute the length of the String; it

packages/yew/src/html/conversion/into_prop_value.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ use implicit_clone::unsync::{IArray, IMap};
66
pub use implicit_clone::ImplicitClone;
77

88
use crate::callback::Callback;
9-
use crate::html::{BaseComponent, ChildrenRenderer, Component, NodeRef, Scope};
9+
use crate::html::{BaseComponent, ChildrenRenderer, Component, Scope};
1010
use crate::virtual_dom::{AttrValue, VChild, VList, VNode, VText};
1111

12-
impl ImplicitClone for NodeRef {}
1312
impl<Comp: Component> ImplicitClone for Scope<Comp> {}
1413
// TODO there are still a few missing
1514

packages/yew/src/html/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl IntoHtmlResult for Html {
8787
/// ```
8888
/// ## Relevant examples
8989
/// - [Node Refs](https://github.com/yewstack/yew/tree/master/examples/node_refs)
90-
#[derive(Default, Clone)]
90+
#[derive(Default, Clone, ImplicitClone)]
9191
pub struct NodeRef(Rc<RefCell<NodeRefInner>>);
9292

9393
impl PartialEq for NodeRef {

packages/yew/src/virtual_dom/key.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::html::ImplicitClone;
99
/// Represents the (optional) key of Yew's virtual nodes.
1010
///
1111
/// Keys are cheap to clone.
12-
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
12+
#[derive(Clone, ImplicitClone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
1313
pub struct Key {
1414
key: Rc<str>,
1515
}
@@ -41,8 +41,6 @@ impl From<&'_ str> for Key {
4141
}
4242
}
4343

44-
impl ImplicitClone for Key {}
45-
4644
macro_rules! key_impl_from_to_string {
4745
($type:ty) => {
4846
impl From<$type> for Key {

packages/yew/src/virtual_dom/listeners.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,17 @@ gen_listener_kinds! {
160160
}
161161

162162
/// A list of event listeners
163-
#[derive(Debug)]
163+
#[derive(Debug, Clone, ImplicitClone, Default)]
164164
pub enum Listeners {
165165
/// No listeners registered or pending.
166166
/// Distinct from `Pending` with an empty slice to avoid an allocation.
167+
#[default]
167168
None,
168169

169170
/// Not yet added to the element or registry
170171
Pending(Box<[Option<Rc<dyn Listener>>]>),
171172
}
172173

173-
impl ImplicitClone for Listeners {}
174-
175174
impl PartialEq for Listeners {
176175
fn eq(&self, rhs: &Self) -> bool {
177176
use Listeners::*;
@@ -201,18 +200,3 @@ impl PartialEq for Listeners {
201200
}
202201
}
203202
}
204-
205-
impl Clone for Listeners {
206-
fn clone(&self) -> Self {
207-
match self {
208-
Self::None => Self::None,
209-
Self::Pending(v) => Self::Pending(v.clone()),
210-
}
211-
}
212-
}
213-
214-
impl Default for Listeners {
215-
fn default() -> Self {
216-
Self::None
217-
}
218-
}

packages/yew/src/virtual_dom/vlist.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::rc::Rc;
55
use super::{Key, VNode};
66
use crate::html::ImplicitClone;
77

8-
#[derive(Clone, Copy, Debug, PartialEq)]
8+
#[derive(Clone, ImplicitClone, Copy, Debug, PartialEq)]
99
enum FullyKeyedState {
1010
KnownFullyKeyed,
1111
KnownMissingKeys,
@@ -24,8 +24,6 @@ pub struct VList {
2424
pub key: Option<Key>,
2525
}
2626

27-
impl ImplicitClone for VList {}
28-
2927
impl PartialEq for VList {
3028
fn eq(&self, other: &Self) -> bool {
3129
self.key == other.key && self.children == other.children

0 commit comments

Comments
 (0)