Skip to content

Commit

Permalink
Clippy fixes (#2881)
Browse files Browse the repository at this point in the history
* Clippy in root

* Clippy in examples

* didn't mean to commit this file
  • Loading branch information
ranile committed Sep 25, 2022
1 parent 6751946 commit 7e24fb3
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/boids/src/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-macro/src/function_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
));
}
Expand Down
8 changes: 4 additions & 4 deletions packages/yew-macro/src/hook/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand All @@ -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));
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/dom_bundle/btag/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } => {
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/dom_bundle/btag/listeners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/dom_bundle/subtree_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/functional/hooks/use_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
type Target = T;

fn deref(&self) -> &Self::Target {
&*self.value
&self.value
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/functional/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/html/component/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/html/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7e24fb3

Please sign in to comment.