diff --git a/thaw/src/alert/mod.rs b/thaw/src/alert/mod.rs index cf3bdf4..d22b34c 100644 --- a/thaw/src/alert/mod.rs +++ b/thaw/src/alert/mod.rs @@ -75,13 +75,10 @@ pub fn Alert( css_vars } }); - let icon = create_memo(move |_| { - match variant.get() { - AlertVariant::Success => icondata::AiCheckCircleFilled, - AlertVariant::Warning => icondata::AiExclamationCircleFilled, - AlertVariant::Error => icondata::AiCloseCircleFilled, - } - .into() + let icon = create_memo(move |_| match variant.get() { + AlertVariant::Success => icondata::AiCheckCircleFilled, + AlertVariant::Warning => icondata::AiExclamationCircleFilled, + AlertVariant::Error => icondata::AiCloseCircleFilled, }); view! { diff --git a/thaw/src/checkbox/checkbox_item.rs b/thaw/src/checkbox/checkbox_item.rs index cba4757..3ff01e9 100644 --- a/thaw/src/checkbox/checkbox_item.rs +++ b/thaw/src/checkbox/checkbox_item.rs @@ -23,10 +23,8 @@ pub fn CheckboxItem( if !checked.get_untracked() { checked.set(true); } - } else { - if checked.get_untracked() { - checked.set(false); - } + } else if checked.get_untracked() { + checked.set(false); } }); diff --git a/thaw/src/collapse/collapse_item.rs b/thaw/src/collapse/collapse_item.rs index 36cb614..71fa83c 100644 --- a/thaw/src/collapse/collapse_item.rs +++ b/thaw/src/collapse/collapse_item.rs @@ -18,13 +18,9 @@ pub fn CollapseItem( let content_ref = create_node_ref::(); let is_show_content = create_memo(move |_| { - collapse.value.with(|keys| { - if key.with(|key| keys.contains(key)) { - true - } else { - false - } - }) + collapse + .value + .with(|keys| key.with(|key| keys.contains(key))) }); let on_click = move |_| { diff --git a/thaw/src/input/mod.rs b/thaw/src/input/mod.rs index 0dbce34..800b2ef 100644 --- a/thaw/src/input/mod.rs +++ b/thaw/src/input/mod.rs @@ -144,7 +144,7 @@ pub fn Input( #[cfg(debug_assertions)] { - const INNER_ATTRS: [&'static str; 4] = ["type", "class", "disabled", "placeholder"]; + const INNER_ATTRS: [&str; 4] = ["type", "class", "disabled", "placeholder"]; attrs.iter().for_each(|attr| { if INNER_ATTRS.contains(&attr.0) { logging::warn!( diff --git a/thaw/src/input/text_area.rs b/thaw/src/input/text_area.rs index ef6d776..fb204c8 100644 --- a/thaw/src/input/text_area.rs +++ b/thaw/src/input/text_area.rs @@ -92,7 +92,7 @@ pub fn TextArea( #[cfg(debug_assertions)] { - const INNER_ATTRS: [&'static str; 3] = ["class", "disabled", "placeholder"]; + const INNER_ATTRS: [&str; 3] = ["class", "disabled", "placeholder"]; attrs.iter().for_each(|attr| { if INNER_ATTRS.contains(&attr.0) { logging::warn!( diff --git a/thaw/src/utils/model.rs b/thaw/src/utils/model.rs index 1731161..c1bed24 100644 --- a/thaw/src/utils/model.rs +++ b/thaw/src/utils/model.rs @@ -20,11 +20,7 @@ impl Default for Model { impl Clone for Model { fn clone(&self) -> Self { - Self { - read: self.read.clone(), - write: self.write.clone(), - on_write: self.on_write.clone(), - } + *self } } @@ -37,7 +33,7 @@ impl Model { } pub fn signal(&self) -> Signal { - self.read.clone() + self.read } } @@ -159,7 +155,7 @@ impl From<(Memo, WriteSignal)> for Model { impl From<(Option, WriteSignal)> for Model { fn from((read, write): (Option, WriteSignal)) -> Self { let mut model = Self::new(read.unwrap_or_default()); - model.on_write = Some(write.into()); + model.on_write = Some(write); model } } diff --git a/thaw/src/utils/optional_prop.rs b/thaw/src/utils/optional_prop.rs index 8cc4b22..eca37c6 100644 --- a/thaw/src/utils/optional_prop.rs +++ b/thaw/src/utils/optional_prop.rs @@ -20,10 +20,7 @@ impl OptionalProp { where F: FnOnce(T) -> U, { - match self.0 { - Some(x) => Some(f(x)), - None => None, - } + self.0.map(f) } pub fn into_option(self) -> Option {