mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-23 00:03:27 +01:00
HighlightingAssets: Simplify absolute_path with .map_or_else()
This commit is contained in:
parent
b034879eae
commit
82f439e715
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user