diff --git a/src/xdg_user_dirs.rs b/src/xdg_user_dirs.rs index de7e9e9..2803fd4 100644 --- a/src/xdg_user_dirs.rs +++ b/src/xdg_user_dirs.rs @@ -32,7 +32,7 @@ fn parse_user_dirs(home_dir: &Path, user_dir: Option<&str>, bytes: &[u8]) -> Has let key = if key.starts_with(b"XDG_") && key.ends_with(b"_DIR") { match str::from_utf8(&key[4..key.len()-4]) { Ok(key) => - if user_dir.is_some() && option_contains(user_dir, key) { + if user_dir == Some(key) { single_dir_found = true; key } else if user_dir.is_none() { @@ -137,18 +137,12 @@ fn shell_unescape(escaped: &[u8]) -> Vec { unescaped } -fn option_contains(option: Option, value: T) -> bool { - match option { - Some(val) => val == value, - None => false - } -} - #[cfg(test)] mod tests { use std::collections::HashMap; use std::path::{Path, PathBuf}; - use super::{trim_blank, shell_unescape, split_once, parse_user_dirs}; + + use super::{parse_user_dirs, shell_unescape, split_once, trim_blank}; #[test] fn test_trim_blank() {