1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

use map_or and map_or_else

This commit is contained in:
Emil Ernerfeldt
2021-10-20 16:33:59 +02:00
parent a0cd41755e
commit 40445c450c
8 changed files with 26 additions and 41 deletions

View File

@@ -319,8 +319,7 @@ impl<'a> Iterator for Parser<'a> {
let end = self
.s
.find(&['*', '`', '~', '_', '/', '$', '^', '\\', '<', '[', '\n'][..])
.map(|special| special.max(1)) // make sure we swallow at least one character
.unwrap_or_else(|| self.s.len());
.map_or_else(|| self.s.len(), |special| special.max(1));
let item = Item::Text(self.style, &self.s[..end]);
self.s = &self.s[end..];