Skip to content

Commit

Permalink
refactor(desktop file): simplify some none-type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed Jan 24, 2024
1 parent 754e339 commit 996ad7e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/desktop_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ fn find_desktop_file_by_filedata(app_id: &str, files: &[PathBuf]) -> Option<Path
let files = files
.iter()
.filter_map(|file| {
let Some(parsed_desktop_file) = parse_desktop_file(file) else {
return None;
};
let parsed_desktop_file = parse_desktop_file(file)?;

desktop_files_cache.insert(file.clone(), parsed_desktop_file.clone());
Some((file.clone(), parsed_desktop_file))
Expand Down Expand Up @@ -165,9 +163,7 @@ fn parse_desktop_file(path: &Path) -> Option<DesktopFile> {

file.lines()
.filter_map(|line| {
let Some((key, value)) = line.split_once('=') else {
return None;
};
let (key, value) = line.split_once('=')?;

let key = key.trim();
let value = value.trim();
Expand All @@ -190,9 +186,7 @@ fn parse_desktop_file(path: &Path) -> Option<DesktopFile> {

/// Attempts to get the icon name from the app's `.desktop` file.
pub fn get_desktop_icon_name(app_id: &str) -> Option<String> {
let Some(path) = find_desktop_file(app_id) else {
return None;
};
let path = find_desktop_file(app_id)?;

let mut desktop_files_cache = lock!(desktop_files());

Expand Down

0 comments on commit 996ad7e

Please sign in to comment.