Clippy fixes (#2881)

* Clippy in root

* Clippy in examples

* didn't mean to commit this file
This commit is contained in:
Muhammad Hamza 2022-09-25 17:25:23 +05:00 committed by GitHub
parent 6751946477
commit 7e24fb3c58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 15 additions and 15 deletions

View File

@ -56,7 +56,7 @@ impl Component for Slider {
step,
} = *ctx.props();
let precision = precision.unwrap_or(if percentage { 1 } else { 0 });
let precision = precision.unwrap_or_else(|| usize::from(percentage));
let display_value = if percentage {
format!("{:.p$}%", 100.0 * value, p = precision)

View File

@ -42,7 +42,7 @@ pub fn ChessboardCard(props: &Props) -> Html {
html! {
<div class="chess-board-card-container">
<div class={classes!("card", flipped.then(|| "flipped"))} {onclick}>
<div class={classes!("card", flipped.then_some("flipped"))} {onclick}>
<img class="front" src={get_link_by_cardname} alt="card" />
<img class="back" src="public/back.png" alt="card" />
</div>

View File

@ -102,7 +102,7 @@ impl Parse for FunctionComponent {
if ty.mutability.is_some() {
return Err(syn::Error::new_spanned(
&ty.mutability,
ty.mutability,
"reference must not be mutable",
));
}

View File

@ -98,12 +98,12 @@ impl VisitMut for BodyRewriter {
visit_mut::visit_attribute_mut(self, it);
}
visit_mut::visit_expr_mut(self, &mut *i.cond);
visit_mut::visit_expr_mut(self, &mut i.cond);
self.with_branch(|m| visit_mut::visit_block_mut(m, &mut i.then_branch));
if let Some(it) = &mut i.else_branch {
self.with_branch(|m| visit_mut::visit_expr_mut(m, &mut *(it).1));
self.with_branch(|m| visit_mut::visit_expr_mut(m, &mut (it).1));
}
}
@ -119,7 +119,7 @@ impl VisitMut for BodyRewriter {
visit_mut::visit_label_mut(self, it);
}
visit_mut::visit_pat_mut(self, &mut i.pat);
visit_mut::visit_expr_mut(self, &mut *i.expr);
visit_mut::visit_expr_mut(self, &mut i.expr);
self.with_branch(|m| visit_mut::visit_block_mut(m, &mut i.body));
}
@ -129,7 +129,7 @@ impl VisitMut for BodyRewriter {
visit_mut::visit_attribute_mut(self, it);
}
visit_mut::visit_expr_mut(self, &mut *i.expr);
visit_mut::visit_expr_mut(self, &mut i.expr);
self.with_branch(|m| {
for it in &mut i.arms {

View File

@ -192,7 +192,7 @@ impl Apply for Attributes {
match &self {
Self::Static(arr) => {
for (k, v, apply_as) in arr.iter() {
Self::set(el, *k, *v, *apply_as);
Self::set(el, k, v, *apply_as);
}
}
Self::Dynamic { keys, values } => {

View File

@ -66,7 +66,7 @@ impl Apply for Listeners {
(Pending(pending), Registered(ref id)) => {
// Reuse the ID
test_log!("reusing listeners for {}", id);
root.with_listener_registry(|reg| reg.patch(root, id, &*pending));
root.with_listener_registry(|reg| reg.patch(root, id, &pending));
}
(Pending(pending), bundle @ NoReg) => {
*bundle = ListenerRegistration::register(root, el, &pending);

View File

@ -484,7 +484,7 @@ impl BSubtree {
/// Run f with access to global Registry
#[inline]
pub fn with_listener_registry<R>(&self, f: impl FnOnce(&mut Registry) -> R) -> R {
f(&mut *self.0.event_registry().borrow_mut())
f(&mut self.0.event_registry().borrow_mut())
}
pub fn brand_element(&self, el: &dyn EventGrating) {

View File

@ -59,7 +59,7 @@ where
type Target = T;
fn deref(&self) -> &Self::Target {
&*self.value
&self.value
}
}

View File

@ -356,7 +356,7 @@ where
hook_ctx.prepare_run();
#[allow(clippy::let_and_return)]
let result = T::run(&mut *hook_ctx, props);
let result = T::run(&mut hook_ctx, props);
#[cfg(debug_assertions)]
hook_ctx.assert_hook_context(result.is_ok());

View File

@ -206,7 +206,7 @@ where
if self.context.props != props {
let old_props = std::mem::replace(&mut self.context.props, props);
self.component.changed(&self.context, &*old_props)
self.component.changed(&self.context, &old_props)
} else {
false
}

View File

@ -50,7 +50,7 @@ impl<COMP: BaseComponent> Context<COMP> {
/// The component's props
#[inline]
pub fn props(&self) -> &COMP::Properties {
&*self.props
&self.props
}
#[cfg(feature = "hydration")]

View File

@ -96,7 +96,7 @@ fn with<R>(f: impl FnOnce(&mut Scheduler) -> R) -> R {
static SCHEDULER: RefCell<Scheduler> = Default::default();
}
SCHEDULER.with(|s| f(&mut *s.borrow_mut()))
SCHEDULER.with(|s| f(&mut s.borrow_mut()))
}
/// Push a generic [Runnable] to be executed