@@ -67,100 +67,100 @@ pub trait UpdateEl<T> {
67
67
fn update ( self , el : & mut T ) ;
68
68
}
69
69
70
- impl < Ms : Clone > UpdateEl < El < Ms > > for Attrs {
70
+ impl < Ms > UpdateEl < El < Ms > > for Attrs {
71
71
fn update ( self , el : & mut El < Ms > ) {
72
72
el. attrs . merge ( self ) ;
73
73
}
74
74
}
75
75
76
- impl < Ms : Clone > UpdateEl < El < Ms > > for & Attrs {
76
+ impl < Ms > UpdateEl < El < Ms > > for & Attrs {
77
77
fn update ( self , el : & mut El < Ms > ) {
78
78
el. attrs . merge ( self . clone ( ) ) ;
79
79
}
80
80
}
81
81
82
- impl < Ms : Clone > UpdateEl < El < Ms > > for Style {
82
+ impl < Ms > UpdateEl < El < Ms > > for Style {
83
83
fn update ( self , el : & mut El < Ms > ) {
84
84
el. style . merge ( self ) ;
85
85
}
86
86
}
87
87
88
- impl < Ms : Clone > UpdateEl < El < Ms > > for & Style {
88
+ impl < Ms > UpdateEl < El < Ms > > for & Style {
89
89
fn update ( self , el : & mut El < Ms > ) {
90
90
el. style . merge ( self . clone ( ) ) ;
91
91
}
92
92
}
93
93
94
- impl < Ms : Clone > UpdateEl < El < Ms > > for Listener < Ms > {
94
+ impl < Ms > UpdateEl < El < Ms > > for Listener < Ms > {
95
95
fn update ( self , el : & mut El < Ms > ) {
96
96
el. listeners . push ( self )
97
97
}
98
98
}
99
99
100
- impl < Ms : Clone > UpdateEl < El < Ms > > for Vec < Listener < Ms > > {
100
+ impl < Ms > UpdateEl < El < Ms > > for Vec < Listener < Ms > > {
101
101
fn update ( mut self , el : & mut El < Ms > ) {
102
102
el. listeners . append ( & mut self ) ;
103
103
}
104
104
}
105
105
106
- impl < Ms : Clone > UpdateEl < El < Ms > > for DidMount < Ms > {
106
+ impl < Ms > UpdateEl < El < Ms > > for DidMount < Ms > {
107
107
fn update ( self , el : & mut El < Ms > ) {
108
108
el. hooks . did_mount = Some ( self )
109
109
}
110
110
}
111
111
112
- impl < Ms : Clone > UpdateEl < El < Ms > > for DidUpdate < Ms > {
112
+ impl < Ms > UpdateEl < El < Ms > > for DidUpdate < Ms > {
113
113
fn update ( self , el : & mut El < Ms > ) {
114
114
el. hooks . did_update = Some ( self )
115
115
}
116
116
}
117
117
118
- impl < Ms : Clone > UpdateEl < El < Ms > > for WillUnmount < Ms > {
118
+ impl < Ms > UpdateEl < El < Ms > > for WillUnmount < Ms > {
119
119
fn update ( self , el : & mut El < Ms > ) {
120
120
el. hooks . will_unmount = Some ( self )
121
121
}
122
122
}
123
123
124
- impl < Ms : Clone > UpdateEl < El < Ms > > for & str {
124
+ impl < Ms > UpdateEl < El < Ms > > for & str {
125
125
// This, or some other mechanism seems to work for String too... note sure why.
126
126
fn update ( self , el : & mut El < Ms > ) {
127
127
el. children . push ( Node :: Text ( Text :: new ( self . to_string ( ) ) ) )
128
128
}
129
129
}
130
130
131
- impl < Ms : Clone > UpdateEl < El < Ms > > for El < Ms > {
131
+ impl < Ms > UpdateEl < El < Ms > > for El < Ms > {
132
132
fn update ( self , el : & mut El < Ms > ) {
133
133
el. children . push ( Node :: Element ( self ) )
134
134
}
135
135
}
136
136
137
- impl < Ms : Clone > UpdateEl < El < Ms > > for Vec < El < Ms > > {
137
+ impl < Ms > UpdateEl < El < Ms > > for Vec < El < Ms > > {
138
138
fn update ( self , el : & mut El < Ms > ) {
139
139
el. children
140
140
. append ( & mut self . into_iter ( ) . map ( Node :: Element ) . collect ( ) ) ;
141
141
}
142
142
}
143
143
144
- impl < Ms : Clone > UpdateEl < El < Ms > > for Node < Ms > {
144
+ impl < Ms > UpdateEl < El < Ms > > for Node < Ms > {
145
145
fn update ( self , el : & mut El < Ms > ) {
146
146
el. children . push ( self )
147
147
}
148
148
}
149
149
150
- impl < Ms : Clone > UpdateEl < El < Ms > > for Vec < Node < Ms > > {
150
+ impl < Ms > UpdateEl < El < Ms > > for Vec < Node < Ms > > {
151
151
fn update ( mut self , el : & mut El < Ms > ) {
152
152
el. children . append ( & mut self ) ;
153
153
}
154
154
}
155
155
156
156
/// This is intended only to be used for the custom! element macro.
157
- impl < Ms : Clone > UpdateEl < El < Ms > > for Tag {
157
+ impl < Ms > UpdateEl < El < Ms > > for Tag {
158
158
fn update ( self , el : & mut El < Ms > ) {
159
159
el. tag = self ;
160
160
}
161
161
}
162
162
163
- impl < Ms : Clone , I , U , F > UpdateEl < El < Ms > > for std:: iter:: Map < I , F >
163
+ impl < Ms , I , U , F > UpdateEl < El < Ms > > for std:: iter:: Map < I , F >
164
164
where
165
165
I : Iterator ,
166
166
U : UpdateEl < El < Ms > > ,
@@ -669,29 +669,29 @@ make_tags! {
669
669
Placeholder => "placeholder"
670
670
}
671
671
672
- pub trait View < Ms : ' static + Clone > {
672
+ pub trait View < Ms : ' static > {
673
673
fn els ( self ) -> Vec < Node < Ms > > ;
674
674
}
675
675
676
- impl < Ms : Clone > View < Ms > for El < Ms > {
676
+ impl < Ms > View < Ms > for El < Ms > {
677
677
fn els ( self ) -> Vec < Node < Ms > > {
678
678
vec ! [ Node :: Element ( self ) ]
679
679
}
680
680
}
681
681
682
- impl < Ms : Clone > View < Ms > for Vec < El < Ms > > {
682
+ impl < Ms > View < Ms > for Vec < El < Ms > > {
683
683
fn els ( self ) -> Vec < Node < Ms > > {
684
684
self . into_iter ( ) . map ( Node :: Element ) . collect ( )
685
685
}
686
686
}
687
687
688
- impl < Ms : ' static + Clone > View < Ms > for Node < Ms > {
688
+ impl < Ms : ' static > View < Ms > for Node < Ms > {
689
689
fn els ( self ) -> Vec < Node < Ms > > {
690
690
vec ! [ self ]
691
691
}
692
692
}
693
693
694
- impl < Ms : ' static + Clone > View < Ms > for Vec < Node < Ms > > {
694
+ impl < Ms : ' static > View < Ms > for Vec < Node < Ms > > {
695
695
fn els ( self ) -> Vec < Node < Ms > > {
696
696
self
697
697
}
@@ -727,16 +727,25 @@ impl Text {
727
727
728
728
/// An component in our virtual DOM. Related to, but different from
729
729
/// [DOM Nodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType)
730
- #[ derive( Clone , Debug , PartialEq ) ]
731
- pub enum Node < Ms : ' static + Clone > {
730
+ #[ derive( Debug , PartialEq ) ]
731
+ pub enum Node < Ms : ' static > {
732
732
Element ( El < Ms > ) ,
733
733
// Svg(El<Ms>), // May be best to handle using namespace field on El
734
734
Text ( Text ) ,
735
735
Empty ,
736
736
}
737
+ impl < Ms : ' static > Clone for Node < Ms > {
738
+ fn clone ( & self ) -> Self {
739
+ match self {
740
+ Self :: Element ( e) => Self :: Element ( e. clone ( ) ) ,
741
+ Self :: Text ( t) => Self :: Text ( t. clone ( ) ) ,
742
+ Self :: Empty => Self :: Empty ,
743
+ }
744
+ }
745
+ }
737
746
738
747
// Mappers for `El` manipulations.
739
- impl < Ms : Clone > Node < Ms > {
748
+ impl < Ms > Node < Ms > {
740
749
/// See `El::from_markdown`
741
750
pub fn from_markdown ( markdown : & str ) -> Vec < Node < Ms > > {
742
751
El :: from_markdown ( markdown)
@@ -817,7 +826,7 @@ impl<Ms: Clone> Node<Ms> {
817
826
}
818
827
}
819
828
// Workspace manipulations.
820
- impl < Ms : Clone > Node < Ms > {
829
+ impl < Ms > Node < Ms > {
821
830
pub ( crate ) fn strip_ws_nodes ( & mut self ) -> & mut Self {
822
831
match self {
823
832
Node :: Element ( e) => e. strip_ws_nodes ( ) ,
@@ -828,7 +837,7 @@ impl<Ms: Clone> Node<Ms> {
828
837
}
829
838
}
830
839
// Convenience methods for `Node` a la `Result` and `Option`.
831
- impl < Ms : Clone > Node < Ms > {
840
+ impl < Ms > Node < Ms > {
832
841
pub fn new_text ( text : impl Into < Cow < ' static , str > > ) -> Self {
833
842
Node :: Text ( Text :: new ( text) )
834
843
}
@@ -883,7 +892,7 @@ impl<Ms: Clone> Node<Ms> {
883
892
}
884
893
}
885
894
886
- impl < Ms : ' static + Clone , OtherMs : ' static + Clone > MessageMapper < Ms , OtherMs > for Node < Ms > {
895
+ impl < Ms : ' static , OtherMs : ' static > MessageMapper < Ms , OtherMs > for Node < Ms > {
887
896
type SelfWithOtherMs = Node < OtherMs > ;
888
897
/// See note on impl for El
889
898
fn map_message ( self , f : impl FnOnce ( Ms ) -> OtherMs + ' static + Clone ) -> Node < OtherMs > {
@@ -895,7 +904,7 @@ impl<Ms: 'static + Clone, OtherMs: 'static + Clone> MessageMapper<Ms, OtherMs> f
895
904
}
896
905
}
897
906
898
- impl < Ms : ' static + Clone , OtherMs : ' static + Clone > MessageMapper < Ms , OtherMs > for Vec < Node < Ms > > {
907
+ impl < Ms : ' static , OtherMs : ' static > MessageMapper < Ms , OtherMs > for Vec < Node < Ms > > {
899
908
type SelfWithOtherMs = Vec < Node < OtherMs > > ;
900
909
fn map_message ( self , f : impl FnOnce ( Ms ) -> OtherMs + ' static + Clone ) -> Vec < Node < OtherMs > > {
901
910
self . into_iter ( )
@@ -906,7 +915,7 @@ impl<Ms: 'static + Clone, OtherMs: 'static + Clone> MessageMapper<Ms, OtherMs> f
906
915
907
916
/// An component in our virtual DOM.
908
917
#[ derive( Debug ) ] // todo: Custom debug implementation where children are on new lines and indented.
909
- pub struct El < Ms : ' static + Clone > {
918
+ pub struct El < Ms : ' static > {
910
919
// Ms is a message type, as in part of TEA.
911
920
// We call this 'El' instead of 'Element' for brevity, and to prevent
912
921
// confusion with web_sys::Element.
@@ -920,7 +929,7 @@ pub struct El<Ms: 'static + Clone> {
920
929
pub namespace : Option < Namespace > ,
921
930
pub hooks : LifecycleHooks < Ms > ,
922
931
}
923
- impl < Ms : Clone > El < Ms > {
932
+ impl < Ms > El < Ms > {
924
933
pub ( crate ) fn strip_ws_nodes ( & mut self ) {
925
934
self . node_ws . take ( ) ;
926
935
for child in & mut self . children {
@@ -979,7 +988,7 @@ impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for LifecycleHook
979
988
}
980
989
}
981
990
982
- impl < Ms : ' static + Clone , OtherMs : ' static + Clone > MessageMapper < Ms , OtherMs > for El < Ms > {
991
+ impl < Ms : ' static , OtherMs : ' static > MessageMapper < Ms , OtherMs > for El < Ms > {
983
992
type SelfWithOtherMs = El < OtherMs > ;
984
993
/// Maps an element's message to have another message.
985
994
///
@@ -1011,7 +1020,7 @@ impl<Ms: 'static + Clone, OtherMs: 'static + Clone> MessageMapper<Ms, OtherMs> f
1011
1020
}
1012
1021
}
1013
1022
1014
- impl < Ms : ' static + Clone , OtherMs : ' static + Clone > MessageMapper < Ms , OtherMs > for Vec < El < Ms > > {
1023
+ impl < Ms : ' static , OtherMs : ' static > MessageMapper < Ms , OtherMs > for Vec < El < Ms > > {
1015
1024
type SelfWithOtherMs = Vec < El < OtherMs > > ;
1016
1025
fn map_message ( self , f : impl FnOnce ( Ms ) -> OtherMs + ' static + Clone ) -> Vec < El < OtherMs > > {
1017
1026
self . into_iter ( )
@@ -1020,7 +1029,7 @@ impl<Ms: 'static + Clone, OtherMs: 'static + Clone> MessageMapper<Ms, OtherMs> f
1020
1029
}
1021
1030
}
1022
1031
1023
- impl < Ms : Clone > El < Ms > {
1032
+ impl < Ms > El < Ms > {
1024
1033
/// Create an empty element, specifying only the tag
1025
1034
pub fn empty ( tag : Tag ) -> Self {
1026
1035
Self {
@@ -1153,7 +1162,7 @@ impl<Ms: Clone> El<Ms> {
1153
1162
1154
1163
/// Allow the user to clone their Els. Note that there's no easy way to clone the
1155
1164
/// closures within listeners or lifestyle hooks, so we omit them.
1156
- impl < Ms : Clone > Clone for El < Ms > {
1165
+ impl < Ms > Clone for El < Ms > {
1157
1166
fn clone ( & self ) -> Self {
1158
1167
Self {
1159
1168
tag : self . tag . clone ( ) ,
@@ -1168,7 +1177,7 @@ impl<Ms: Clone> Clone for El<Ms> {
1168
1177
}
1169
1178
}
1170
1179
1171
- impl < Ms : Clone > PartialEq for El < Ms > {
1180
+ impl < Ms > PartialEq for El < Ms > {
1172
1181
fn eq ( & self , other : & Self ) -> bool {
1173
1182
// todo Again, note that the listeners check only checks triggers.
1174
1183
// Don't check children.
0 commit comments