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:
@@ -150,8 +150,7 @@ fn remove_leading_indentation(code: &str) -> String {
|
||||
let start = first_line_indent.min(indent);
|
||||
let end = code
|
||||
.find('\n')
|
||||
.map(|endline| endline + 1)
|
||||
.unwrap_or_else(|| code.len());
|
||||
.map_or_else(|| code.len(), |endline| endline + 1);
|
||||
out += &code[start..end];
|
||||
code = &code[end..];
|
||||
}
|
||||
|
||||
@@ -49,11 +49,7 @@ impl super::View for MultiTouch {
|
||||
ui.separator();
|
||||
ui.label("Try touch gestures Pinch/Stretch, Rotation, and Pressure with 2+ fingers.");
|
||||
|
||||
let num_touches = ui
|
||||
.input()
|
||||
.multi_touch()
|
||||
.map(|mt| mt.num_touches)
|
||||
.unwrap_or(0);
|
||||
let num_touches = ui.input().multi_touch().map_or(0, |mt| mt.num_touches);
|
||||
ui.label(format!("Current touches: {}", num_touches));
|
||||
|
||||
Frame::dark_canvas(ui.style()).show(ui, |ui| {
|
||||
|
||||
Reference in New Issue
Block a user