1
Fork 0

Use Option::map_or instead of .map(..).unwrap_or(..)

This commit is contained in:
LingMan 2021-01-11 20:45:33 +01:00
parent d03fe84169
commit a56bffb4f9
50 changed files with 67 additions and 79 deletions

View file

@ -107,7 +107,7 @@ fn t7() {
fn span_from_selection(input: &str, selection: &str) -> Span {
assert_eq!(input.len(), selection.len());
let left_index = selection.find('~').unwrap() as u32;
let right_index = selection.rfind('~').map(|x| x as u32).unwrap_or(left_index);
let right_index = selection.rfind('~').map_or(left_index, |x| x as u32);
Span::with_root_ctxt(BytePos(left_index), BytePos(right_index + 1))
}