HighlightingAssets: Simplify absolute_path with .map_or_else()

This commit is contained in:
Martin Nordholts 2021-09-16 17:02:09 +02:00
parent b034879eae
commit 82f439e715

View File

@ -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) => {