Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 6, 2021
1 parent 7a9805d commit 5e3c522
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 5e3c522

Please sign in to comment.