mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
use map_or and map_or_else
This commit is contained in:
@@ -416,8 +416,7 @@ impl Highligher {
|
||||
} else if text.starts_with(|c: char| c.is_ascii_alphanumeric()) {
|
||||
let end = text[1..]
|
||||
.find(|c: char| !c.is_ascii_alphanumeric())
|
||||
.map(|i| i + 1)
|
||||
.unwrap_or_else(|| text.len());
|
||||
.map_or_else(|| text.len(), |i| i + 1);
|
||||
let word = &text[..end];
|
||||
let tt = if is_keyword(word) {
|
||||
TokenType::Keyword
|
||||
@@ -429,8 +428,7 @@ impl Highligher {
|
||||
} else if text.starts_with(|c: char| c.is_ascii_whitespace()) {
|
||||
let end = text[1..]
|
||||
.find(|c: char| !c.is_ascii_whitespace())
|
||||
.map(|i| i + 1)
|
||||
.unwrap_or_else(|| text.len());
|
||||
.map_or_else(|| text.len(), |i| i + 1);
|
||||
job.append(&text[..end], 0.0, theme.formats[TokenType::Whitespace]);
|
||||
text = &text[end..];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user