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
}
});
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! {

View file

@ -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);
}
});

View file

@ -18,13 +18,9 @@ pub fn CollapseItem(
let content_ref = create_node_ref::<html::Div>();
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 |_| {

View file

@ -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!(

View file

@ -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!(

View file

@ -20,11 +20,7 @@ impl<T: Default> Default for Model<T> {
impl<T> Clone for Model<T> {
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<T> Model<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> {
fn from((read, write): (Option<T>, WriteSignal<T>)) -> Self {
let mut model = Self::new(read.unwrap_or_default());
model.on_write = Some(write.into());
model.on_write = Some(write);
model
}
}

View file

@ -20,10 +20,7 @@ impl<T> OptionalProp<T> {
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<T> {