diff --git a/README.md b/README.md index 0db75f0affd..d7cc42f29d2 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ Properties are also pure Rust types with strict type-checking during the compila ```rust // my_button.rs -#[derive(Clone, Properties, PartialEq)] +#[derive(Properties, PartialEq)] pub struct Properties { pub hidden: bool, #[props(required)] diff --git a/crates/macro/src/lib.rs b/crates/macro/src/lib.rs index 1dcfee4334c..f6216c62f72 100644 --- a/crates/macro/src/lib.rs +++ b/crates/macro/src/lib.rs @@ -13,7 +13,7 @@ //! link: ComponentLink, //! } //! -//! #[derive(Clone, Properties)] +//! #[derive(Properties)] //! struct Props { //! #[props(required)] //! prop: String, diff --git a/examples/custom_components/src/barrier.rs b/examples/custom_components/src/barrier.rs index bd85c923c1f..8653c740199 100644 --- a/examples/custom_components/src/barrier.rs +++ b/examples/custom_components/src/barrier.rs @@ -12,7 +12,7 @@ pub enum Msg { ChildClicked, } -#[derive(Clone, PartialEq, Properties)] +#[derive(PartialEq, Properties)] pub struct Props { pub limit: u32, #[props(required)] diff --git a/examples/custom_components/src/button.rs b/examples/custom_components/src/button.rs index 39047d04876..548b164c689 100644 --- a/examples/custom_components/src/button.rs +++ b/examples/custom_components/src/button.rs @@ -10,7 +10,7 @@ pub enum Msg { Clicked, } -#[derive(Clone, PartialEq, Properties)] +#[derive(PartialEq, Properties)] pub struct Props { pub title: String, #[props(required)] diff --git a/examples/custom_components/src/counter.rs b/examples/custom_components/src/counter.rs index 610e56abf80..5d5c186ef83 100644 --- a/examples/custom_components/src/counter.rs +++ b/examples/custom_components/src/counter.rs @@ -24,7 +24,7 @@ pub enum Msg { Increase, } -#[derive(Clone, PartialEq, Properties)] +#[derive(PartialEq, Properties)] pub struct Props { pub initial: u32, pub color: Color, diff --git a/examples/large_table/src/lib.rs b/examples/large_table/src/lib.rs index bd02b5f112e..828c8acebae 100644 --- a/examples/large_table/src/lib.rs +++ b/examples/large_table/src/lib.rs @@ -36,7 +36,7 @@ impl Component for Model { fn view(&self) -> Html { html! { - { (0..99).map(|row| self.view_row(row)).collect::>() } + { (0..99).map(|row| self.view_row(row)).collect::() }
} } diff --git a/examples/node_refs/src/input.rs b/examples/node_refs/src/input.rs index e26f27c4ad4..6a3931eaee8 100644 --- a/examples/node_refs/src/input.rs +++ b/examples/node_refs/src/input.rs @@ -5,7 +5,7 @@ pub struct InputComponent { link: ComponentLink, } -#[derive(Clone, Properties)] +#[derive(Properties)] pub struct Props { #[props(required)] pub on_hover: Callback<()>, diff --git a/src/html/mod.rs b/src/html/mod.rs index 7698177b77a..b9950dcc1cf 100644 --- a/src/html/mod.rs +++ b/src/html/mod.rs @@ -67,7 +67,7 @@ pub type Html = VNode; /// In this example, the `Wrapper` component is used to wrap other elements. /// ``` ///# use yew::{Children, Html, Properties, Component, ComponentLink, html}; -///# #[derive(Clone, Properties)] +///# #[derive(Properties)] ///# struct WrapperProps { ///# children: Children, ///# } @@ -95,7 +95,7 @@ pub type Html = VNode; /// children property can be used to render the wrapped elements. /// ``` ///# use yew::{Children, Html, Properties, Renderable, Component, ComponentLink, html}; -/// #[derive(Clone, Properties)] +/// #[derive(Properties)] /// struct WrapperProps { /// children: Children, /// } @@ -127,7 +127,7 @@ pub type Children = ChildrenRenderer; /// ``` ///# use yew::{html, Component, Renderable, Html, ComponentLink, ChildrenWithProps, Properties}; ///# -///# #[derive(Clone, Properties)] +///# #[derive(Properties)] ///# struct ListProps { ///# children: ChildrenWithProps, ///# } @@ -139,7 +139,7 @@ pub type Children = ChildrenRenderer; ///# fn update(&mut self, msg: Self::Message) -> bool {unimplemented!()} ///# fn view(&self) -> Html {unimplemented!()} ///# } -///# #[derive(Clone, Properties)] +///# #[derive(Properties)] ///# struct ListItemProps { ///# value: String ///# } @@ -169,7 +169,7 @@ pub type Children = ChildrenRenderer; /// ``` ///# use yew::{html, Component, Html, ChildrenWithProps, ComponentLink, Properties}; ///# -/// #[derive(Clone, Properties)] +/// #[derive(Properties)] /// struct ListProps { /// children: ChildrenWithProps, /// } @@ -191,7 +191,7 @@ pub type Children = ChildrenRenderer; /// } /// } ///# -///# #[derive(Clone, Properties)] +///# #[derive(Properties)] ///# struct ListItemProps { ///# value: String ///# } diff --git a/src/virtual_dom/vtag.rs b/src/virtual_dom/vtag.rs index e3d0b9ede2a..010518e5a56 100644 --- a/src/virtual_dom/vtag.rs +++ b/src/virtual_dom/vtag.rs @@ -160,14 +160,14 @@ impl VTag { /// Adds new listener to the node. /// It's boxed because we want to keep it in a single list. - /// Lates `Listener::attach` called to attach actual listener to a DOM node. + /// Later `Listener::attach` will attach an actual listener to a DOM node. pub fn add_listener(&mut self, listener: Box) { self.listeners.push(listener); } /// Adds new listeners to the node. /// They are boxed because we want to keep them in a single list. - /// Lates `Listener::attach` called to attach actual listener to a DOM node. + /// Later `Listener::attach` will attach an actual listener to a DOM node. pub fn add_listeners(&mut self, listeners: Vec>) { for listener in listeners { self.listeners.push(listener); diff --git a/tests/derive_props/fail.rs b/tests/derive_props/fail.rs index 568f8bf4f59..2b12dce8338 100644 --- a/tests/derive_props/fail.rs +++ b/tests/derive_props/fail.rs @@ -4,9 +4,8 @@ use yew::prelude::*; mod t1 { use super::*; - #[derive(Clone)] struct Value; - #[derive(Clone, Properties)] + #[derive(Properties)] pub struct Props { // ERROR: optional params must implement default value: Value, @@ -15,7 +14,7 @@ mod t1 { mod t2 { use super::*; - #[derive(Clone, Properties)] + #[derive(Properties)] pub struct Props { // ERROR: optional is not a tag #[props(optional)] @@ -25,7 +24,7 @@ mod t2 { mod t3 { use super::*; - #[derive(Clone, Properties)] + #[derive(Properties)] pub struct Props { #[props(required)] value: String, @@ -38,7 +37,7 @@ mod t3 { mod t4 { use super::*; - #[derive(Clone, Properties)] + #[derive(Properties)] pub struct Props { b: i32, #[props(required)] diff --git a/tests/derive_props/fail.stderr b/tests/derive_props/fail.stderr index 8f8f9cf38dd..ca1eca72bb5 100644 --- a/tests/derive_props/fail.stderr +++ b/tests/derive_props/fail.stderr @@ -1,31 +1,31 @@ error: expected `props(required)` - --> $DIR/fail.rs:21:11 + --> $DIR/fail.rs:20:11 | -21 | #[props(optional)] +20 | #[props(optional)] | ^^^^^ error[E0277]: the trait bound `t1::Value: std::default::Default` is not satisfied - --> $DIR/fail.rs:9:21 + --> $DIR/fail.rs:8:14 | -9 | #[derive(Clone, Properties)] - | ^^^^^^^^^^ the trait `std::default::Default` is not implemented for `t1::Value` +8 | #[derive(Properties)] + | ^^^^^^^^^^ the trait `std::default::Default` is not implemented for `t1::Value` | = note: required by `std::default::Default::default` error[E0599]: no method named `build` found for type `t3::PropsBuilder` in the current scope - --> $DIR/fail.rs:35:26 + --> $DIR/fail.rs:34:26 | -28 | #[derive(Clone, Properties)] - | - method `build` not found for this +27 | #[derive(Properties)] + | - method `build` not found for this ... -35 | Props::builder().build(); +34 | Props::builder().build(); | ^^^^^ method not found in `t3::PropsBuilder` error[E0599]: no method named `b` found for type `t4::PropsBuilder` in the current scope - --> $DIR/fail.rs:49:26 + --> $DIR/fail.rs:48:26 | -41 | #[derive(Clone, Properties)] - | - method `b` not found for this +40 | #[derive(Properties)] + | - method `b` not found for this ... -49 | Props::builder().b(1).a(2).build(); +48 | Props::builder().b(1).a(2).build(); | ^ help: there is a method with a similar name: `a` diff --git a/tests/derive_props/pass.rs b/tests/derive_props/pass.rs index 76ed11fc74c..57165bb19a7 100644 --- a/tests/derive_props/pass.rs +++ b/tests/derive_props/pass.rs @@ -5,8 +5,8 @@ use yew::prelude::*; mod t1 { use super::*; - #[derive(Clone, Properties)] - pub struct Props { + #[derive(Properties)] + pub struct Props { value: T, } @@ -19,10 +19,9 @@ mod t1 { mod t2 { use super::*; - #[derive(Clone)] struct Value; - #[derive(Clone, Properties)] - pub struct Props { + #[derive(Properties)] + pub struct Props { #[props(required)] value: T, } @@ -35,7 +34,7 @@ mod t2 { mod t3 { use super::*; - #[derive(Clone, Properties)] + #[derive(Properties)] pub struct Props { #[props(required)] b: i32, @@ -51,10 +50,10 @@ mod t3 { mod t4 { use super::*; - #[derive(Clone, Properties)] + #[derive(Properties)] pub struct Props where - T: Clone + Default, + T: Default, { value: T, } @@ -68,8 +67,8 @@ mod t4 { mod t5 { use super::*; - #[derive(Clone, Properties)] - pub struct Props<'a, T: Clone + Default + 'a> { + #[derive(Properties)] + pub struct Props<'a, T: Default + 'a> { static_value: &'static str, #[props(required)] value: &'a T, diff --git a/tests/macro/html-component-pass.rs b/tests/macro/html-component-pass.rs index 02f4c7e5376..68d868fb960 100644 --- a/tests/macro/html-component-pass.rs +++ b/tests/macro/html-component-pass.rs @@ -5,7 +5,7 @@ mod helpers; use yew::html::ChildrenRenderer; -#[derive(Clone, Properties, Default, PartialEq)] +#[derive(Properties, Default, PartialEq)] pub struct ChildProperties { pub string: String, #[props(required)] @@ -32,7 +32,7 @@ impl Component for Child { } } -#[derive(Clone, Properties, Default)] +#[derive(Properties, Default)] pub struct ContainerProperties { #[props(required)] pub int: i32, @@ -57,7 +57,7 @@ impl Component for Container { } } -#[derive(Clone, Properties, Default)] +#[derive(Properties, Default)] pub struct ChildContainerProperties { #[props(required)] pub int: i32, diff --git a/tests/macro/test_component.rs b/tests/macro/test_component.rs index b4afc83b6ca..252c1846a4f 100644 --- a/tests/macro/test_component.rs +++ b/tests/macro/test_component.rs @@ -1,6 +1,6 @@ use yew::prelude::*; -#[derive(Clone, Properties, PartialEq)] +#[derive(Properties, PartialEq)] pub struct TestProperties { pub string: String, pub int: i32, diff --git a/tests/vcomp_test.rs b/tests/vcomp_test.rs index f15a32ed64d..d3c7e5afe98 100644 --- a/tests/vcomp_test.rs +++ b/tests/vcomp_test.rs @@ -8,7 +8,7 @@ wasm_bindgen_test_configure!(run_in_browser); struct Comp; -#[derive(Clone, PartialEq, Properties)] +#[derive(PartialEq, Properties)] struct Props { field_1: u32, field_2: u32, diff --git a/tests/vlist_test.rs b/tests/vlist_test.rs index bf42260b06d..02bee958017 100644 --- a/tests/vlist_test.rs +++ b/tests/vlist_test.rs @@ -30,7 +30,7 @@ fn check_fragments() { <> }; - let _ = html! { + html! {
{ fragment }
diff --git a/tests/vtag_test.rs b/tests/vtag_test.rs index 1b0949e8a41..9e1b2545b32 100644 --- a/tests/vtag_test.rs +++ b/tests/vtag_test.rs @@ -231,9 +231,9 @@ fn supports_multiple_classes_vec() { fn filter_empty_string_classes_vec() { let mut classes = vec![""]; classes.push("class-2"); - let a: VNode = html! {
}; - let b: VNode = html! {
}; - let c: VNode = html! {
}; + let a = html! {
}; + let b = html! {
}; + let c = html! {
}; if let VNode::VTag(vtag) = a { assert!(vtag.classes.is_empty()); diff --git a/tests/vtext_test.rs b/tests/vtext_test.rs index 18786329495..25d85a9baeb 100644 --- a/tests/vtext_test.rs +++ b/tests/vtext_test.rs @@ -26,11 +26,11 @@ impl Component for Comp { #[test] fn text_as_root() { - let _ = html! { + html! { "Text Node As Root" }; - let _ = html! { + html! { { "Text Node As Root" } }; }