From 5e3c522b6ce3f3ef2e44247398ce9e56350d7544 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 6 Sep 2021 21:23:57 +0200 Subject: [PATCH] clippy fixes --- egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs b/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs index 008b8a1a307..e1850aa9d68 100644 --- a/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs +++ b/egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs @@ -28,7 +28,10 @@ pub fn highlight_easymark(visuals: &egui::Visuals, mut text: &str) -> egui::text while !text.is_empty() { if start_of_line && text.starts_with("```") { - let end = text.find("\n```").map(|i| i + 4).unwrap_or(text.len()); + let end = text + .find("\n```") + .map(|i| i + 4) + .unwrap_or_else(|| text.len()); job.append( &text[..end], 0.0, @@ -45,12 +48,12 @@ pub fn highlight_easymark(visuals: &egui::Visuals, mut text: &str) -> egui::text continue; } - if text.starts_with("`") { + if text.starts_with('`') { style.code = true; let end = text[1..] .find(&['`', '\n'][..]) .map(|i| i + 2) - .unwrap_or(text.len()); + .unwrap_or_else(|| text.len()); job.append(&text[..end], 0.0, format_from_style(visuals, &style)); text = &text[end..]; style.code = false;