mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Clippy fixes (#2881)
* Clippy in root * Clippy in examples * didn't mean to commit this file
This commit is contained in:
parent
6751946477
commit
7e24fb3c58
@ -56,7 +56,7 @@ impl Component for Slider {
|
|||||||
step,
|
step,
|
||||||
} = *ctx.props();
|
} = *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 {
|
let display_value = if percentage {
|
||||||
format!("{:.p$}%", 100.0 * value, p = precision)
|
format!("{:.p$}%", 100.0 * value, p = precision)
|
||||||
|
|||||||
@ -42,7 +42,7 @@ pub fn ChessboardCard(props: &Props) -> Html {
|
|||||||
|
|
||||||
html! {
|
html! {
|
||||||
<div class="chess-board-card-container">
|
<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="front" src={get_link_by_cardname} alt="card" />
|
||||||
<img class="back" src="public/back.png" alt="card" />
|
<img class="back" src="public/back.png" alt="card" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -102,7 +102,7 @@ impl Parse for FunctionComponent {
|
|||||||
|
|
||||||
if ty.mutability.is_some() {
|
if ty.mutability.is_some() {
|
||||||
return Err(syn::Error::new_spanned(
|
return Err(syn::Error::new_spanned(
|
||||||
&ty.mutability,
|
ty.mutability,
|
||||||
"reference must not be mutable",
|
"reference must not be mutable",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,12 +98,12 @@ impl VisitMut for BodyRewriter {
|
|||||||
visit_mut::visit_attribute_mut(self, it);
|
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));
|
self.with_branch(|m| visit_mut::visit_block_mut(m, &mut i.then_branch));
|
||||||
|
|
||||||
if let Some(it) = &mut i.else_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_label_mut(self, it);
|
||||||
}
|
}
|
||||||
visit_mut::visit_pat_mut(self, &mut i.pat);
|
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));
|
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_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| {
|
self.with_branch(|m| {
|
||||||
for it in &mut i.arms {
|
for it in &mut i.arms {
|
||||||
|
|||||||
@ -192,7 +192,7 @@ impl Apply for Attributes {
|
|||||||
match &self {
|
match &self {
|
||||||
Self::Static(arr) => {
|
Self::Static(arr) => {
|
||||||
for (k, v, apply_as) in arr.iter() {
|
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 } => {
|
Self::Dynamic { keys, values } => {
|
||||||
|
|||||||
@ -66,7 +66,7 @@ impl Apply for Listeners {
|
|||||||
(Pending(pending), Registered(ref id)) => {
|
(Pending(pending), Registered(ref id)) => {
|
||||||
// Reuse the ID
|
// Reuse the ID
|
||||||
test_log!("reusing listeners for {}", 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) => {
|
(Pending(pending), bundle @ NoReg) => {
|
||||||
*bundle = ListenerRegistration::register(root, el, &pending);
|
*bundle = ListenerRegistration::register(root, el, &pending);
|
||||||
|
|||||||
@ -484,7 +484,7 @@ impl BSubtree {
|
|||||||
/// Run f with access to global Registry
|
/// Run f with access to global Registry
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_listener_registry<R>(&self, f: impl FnOnce(&mut Registry) -> R) -> R {
|
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) {
|
pub fn brand_element(&self, el: &dyn EventGrating) {
|
||||||
|
|||||||
@ -59,7 +59,7 @@ where
|
|||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&*self.value
|
&self.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -356,7 +356,7 @@ where
|
|||||||
hook_ctx.prepare_run();
|
hook_ctx.prepare_run();
|
||||||
|
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
let result = T::run(&mut *hook_ctx, props);
|
let result = T::run(&mut hook_ctx, props);
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
hook_ctx.assert_hook_context(result.is_ok());
|
hook_ctx.assert_hook_context(result.is_ok());
|
||||||
|
|||||||
@ -206,7 +206,7 @@ where
|
|||||||
|
|
||||||
if self.context.props != props {
|
if self.context.props != props {
|
||||||
let old_props = std::mem::replace(&mut 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 {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ impl<COMP: BaseComponent> Context<COMP> {
|
|||||||
/// The component's props
|
/// The component's props
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn props(&self) -> &COMP::Properties {
|
pub fn props(&self) -> &COMP::Properties {
|
||||||
&*self.props
|
&self.props
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "hydration")]
|
#[cfg(feature = "hydration")]
|
||||||
|
|||||||
@ -96,7 +96,7 @@ fn with<R>(f: impl FnOnce(&mut Scheduler) -> R) -> R {
|
|||||||
static SCHEDULER: RefCell<Scheduler> = Default::default();
|
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
|
/// Push a generic [Runnable] to be executed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user