pref: cargo clippy

This commit is contained in:
luoxiao 2024-02-01 15:33:56 +08:00 committed by luoxiaozero
parent 8bdbda33a0
commit 706ca144c6
7 changed files with 15 additions and 31 deletions

View file

@ -75,13 +75,10 @@ pub fn Alert(
css_vars css_vars
} }
}); });
let icon = create_memo(move |_| { let icon = create_memo(move |_| match variant.get() {
match variant.get() {
AlertVariant::Success => icondata::AiCheckCircleFilled, AlertVariant::Success => icondata::AiCheckCircleFilled,
AlertVariant::Warning => icondata::AiExclamationCircleFilled, AlertVariant::Warning => icondata::AiExclamationCircleFilled,
AlertVariant::Error => icondata::AiCloseCircleFilled, AlertVariant::Error => icondata::AiCloseCircleFilled,
}
.into()
}); });
view! { view! {

View file

@ -23,11 +23,9 @@ pub fn CheckboxItem(
if !checked.get_untracked() { if !checked.get_untracked() {
checked.set(true); checked.set(true);
} }
} else { } else if checked.get_untracked() {
if checked.get_untracked() {
checked.set(false); checked.set(false);
} }
}
}); });
_ = checked.watch(move |checked| { _ = checked.watch(move |checked| {

View file

@ -18,13 +18,9 @@ pub fn CollapseItem(
let content_ref = create_node_ref::<html::Div>(); let content_ref = create_node_ref::<html::Div>();
let is_show_content = create_memo(move |_| { let is_show_content = create_memo(move |_| {
collapse.value.with(|keys| { collapse
if key.with(|key| keys.contains(key)) { .value
true .with(|keys| key.with(|key| keys.contains(key)))
} else {
false
}
})
}); });
let on_click = move |_| { let on_click = move |_| {

View file

@ -144,7 +144,7 @@ pub fn Input(
#[cfg(debug_assertions)] #[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| { attrs.iter().for_each(|attr| {
if INNER_ATTRS.contains(&attr.0) { if INNER_ATTRS.contains(&attr.0) {
logging::warn!( logging::warn!(

View file

@ -92,7 +92,7 @@ pub fn TextArea(
#[cfg(debug_assertions)] #[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| { attrs.iter().for_each(|attr| {
if INNER_ATTRS.contains(&attr.0) { if INNER_ATTRS.contains(&attr.0) {
logging::warn!( logging::warn!(

View file

@ -20,11 +20,7 @@ impl<T: Default> Default for Model<T> {
impl<T> Clone for Model<T> { impl<T> Clone for Model<T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { *self
read: self.read.clone(),
write: self.write.clone(),
on_write: self.on_write.clone(),
}
} }
} }
@ -37,7 +33,7 @@ impl<T> Model<T> {
} }
pub fn signal(&self) -> Signal<T> { pub fn signal(&self) -> Signal<T> {
self.read.clone() self.read
} }
} }
@ -159,7 +155,7 @@ impl<T> From<(Memo<T>, WriteSignal<T>)> for Model<T> {
impl<T: Default> From<(Option<T>, WriteSignal<T>)> for Model<T> { impl<T: Default> From<(Option<T>, WriteSignal<T>)> for Model<T> {
fn from((read, write): (Option<T>, WriteSignal<T>)) -> Self { fn from((read, write): (Option<T>, WriteSignal<T>)) -> Self {
let mut model = Self::new(read.unwrap_or_default()); let mut model = Self::new(read.unwrap_or_default());
model.on_write = Some(write.into()); model.on_write = Some(write);
model model
} }
} }

View file

@ -20,10 +20,7 @@ impl<T> OptionalProp<T> {
where where
F: FnOnce(T) -> U, F: FnOnce(T) -> U,
{ {
match self.0 { self.0.map(f)
Some(x) => Some(f(x)),
None => None,
}
} }
pub fn into_option(self) -> Option<T> { pub fn into_option(self) -> Option<T> {