From 82f439e71561a423f23e1d09bde98e72569c68b6 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Thu, 16 Sep 2021 17:02:09 +0200 Subject: [PATCH] HighlightingAssets: Simplify absolute_path with .map_or_else() --- src/assets.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index b4fca157..5b166d10 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -212,10 +212,8 @@ impl HighlightingAssets { let path_syntax = if let Some(path) = path { // If a path was provided, we try and detect the syntax based on extension mappings. - let absolute_path = PathAbs::new(path) - .ok() - .map(|p| p.as_path().to_path_buf()) - .unwrap_or_else(|| path.to_owned()); + let absolute_path = + PathAbs::new(path).map_or_else(|_| path.to_owned(), |p| p.as_path().to_path_buf()); match mapping.get_syntax_for(absolute_path) { Some(MappingTarget::MapToUnknown) => {