Skip to content

Commit

Permalink
fix clippy (yewstack#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
voidpumpkin authored 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

0 comments on commit 221b4df

Please sign in to comment.