Skip to content

Commit

Permalink
fix clippy (#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
voidpumpkin committed Mar 5, 2022
1 parent 3a11f15 commit 221b4df
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/boids/src/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Component for Slider {
step,
} = *ctx.props();

let precision = precision.unwrap_or_else(|| if percentage { 1 } else { 0 });
let precision = precision.unwrap_or(if percentage { 1 } else { 0 });

let display_value = if percentage {
format!("{:.p$}%", 100.0 * value, p = precision)
Expand Down
17 changes: 3 additions & 14 deletions examples/futures/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,12 @@ pub fn render_markdown(src: &str) -> Html {
pre.add_child(top.into());
top = pre;
} else if let Tag::Table(aligns) = tag {
for r in top
.children_mut()
.iter_mut()
.map(|ch| ch.iter_mut())
.flatten()
{
for r in top.children_mut().iter_mut().flat_map(|ch| ch.iter_mut()) {
if let VNode::VTag(ref mut vtag) = r {
for (i, c) in vtag
.children_mut()
.iter_mut()
.map(|ch| ch.iter_mut())
.flatten()
.flat_map(|ch| ch.iter_mut())
.enumerate()
{
if let VNode::VTag(ref mut vtag) = c {
Expand All @@ -79,12 +73,7 @@ pub fn render_markdown(src: &str) -> Html {
}
}
} else if let Tag::TableHead = tag {
for c in top
.children_mut()
.iter_mut()
.map(|ch| ch.iter_mut())
.flatten()
{
for c in top.children_mut().iter_mut().flat_map(|ch| ch.iter_mut()) {
if let VNode::VTag(ref mut vtag) = c {
// TODO
// vtag.tag = "th".into();
Expand Down
12 changes: 4 additions & 8 deletions packages/yew/src/virtual_dom/listeners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,7 @@ impl Registry {
fn handle(desc: EventDescriptor, event: Event) {
let target = match event
.target()
.map(|el| el.dyn_into::<web_sys::Element>().ok())
.flatten()
.and_then(|el| el.dyn_into::<web_sys::Element>().ok())
{
Some(el) => el,
None => return,
Expand All @@ -492,18 +491,15 @@ impl Registry {
let run_handler = |el: &web_sys::Element| {
if let Some(l) = LISTENER_ID_PROP
.with(|prop| js_sys::Reflect::get(el, prop).ok())
.map(|v| v.dyn_into().ok())
.flatten()
.map(|num: js_sys::Number| {
.and_then(|v| v.dyn_into().ok())
.and_then(|num: js_sys::Number| {
Registry::with(|r| {
r.by_id
.get(&(num.value_of() as u32))
.map(|s| s.get(&desc))
.flatten()
.and_then(|s| s.get(&desc))
.cloned()
})
})
.flatten()
{
for l in l {
l.handle(event.clone());
Expand Down
2 changes: 1 addition & 1 deletion tools/process-benchmark-results/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> Result<()> {
let transformed_benchmarks: Vec<GhActionBenchmark> = input_json
.into_iter()
.map(|v| GhActionBenchmark {
name: format!("{} {}", v["framework"], v["benchmark"]).replace("\"", ""),
name: format!("{} {}", v["framework"], v["benchmark"]).replace('\"', ""),
unit: String::default(),
value: v["median"].to_string(),
})
Expand Down
2 changes: 1 addition & 1 deletion tools/website-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Level {
.unwrap()
.to_str()
.unwrap()
.replace("-", "_");
.replace('-', "_");

self.write_space(dst, level);

Expand Down

1 comment on commit 221b4df

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yew master branch benchmarks (Lower is better)

Benchmark suite Current: 221b4df Previous: 3a11f15 Ratio
yew-struct-keyed 01_run1k 229.158 210.1425 1.09
yew-struct-keyed 02_replace1k 259.659 226.9655 1.14
yew-struct-keyed 03_update10th1k_x16 442.261 393.74 1.12
yew-struct-keyed 04_select1k 85.5575 89.3675 0.96
yew-struct-keyed 05_swap1k 95.543 102.049 0.94
yew-struct-keyed 06_remove-one-1k 32.479 34.9915 0.93
yew-struct-keyed 07_create10k 2780.947 2382.73 1.17
yew-struct-keyed 08_create1k-after1k_x2 521.0815 467.164 1.12
yew-struct-keyed 09_clear1k_x8 268.7265 186.206 1.44
yew-struct-keyed 21_ready-memory 0.9634475708007812 0.9634475708007812 1
yew-struct-keyed 22_run-memory 1.4966659545898438 1.5028305053710938 1.00
yew-struct-keyed 23_update5-memory 1.5060157775878906 1.4616203308105469 1.03
yew-struct-keyed 24_run5-memory 1.5109291076660156 1.5110435485839844 1.00
yew-struct-keyed 25_run-clear-memory 1.1288795471191406 1.1257438659667969 1.00
yew-struct-keyed 31_startup-ci 1787.7325 1789.48175 1.00
yew-struct-keyed 32_startup-bt 35.86199999999999 37.82199999999999 0.95
yew-struct-keyed 34_startup-totalbytes 359.8974609375 359.8974609375 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.