Skip to content

Commit

Permalink
Merge pull request #15 from ArifRoktim/clippy_lints
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
tesuji committed May 24, 2020
2 parents 6bc5fe4 + a2ae878 commit fc56545
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ jobs:
rustup toolchain install 1.34.0
rustup default 1.34.0
- run: cargo build --all-targets --all

clippy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- run: rustup component add clippy
# FIXME: Remove `-- -A clippy::option_as_ref_deref` when MSRV is bumped past 1.40.0
- run: cargo clippy --all --all-targets -- -A clippy::option_as_ref_deref
4 changes: 2 additions & 2 deletions dirs-sys/src/xdg_user_dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use std::str;

/// Returns all XDG user directories obtained from $(XDG_CONFIG_HOME)/user-dirs.dirs.
pub fn all(home_dir_path: &Path, user_dir_file_path: &Path) -> HashMap<String, PathBuf> {
let bytes = read_all(user_dir_file_path).unwrap_or(Vec::new());
let bytes = read_all(user_dir_file_path).unwrap_or_default();
parse_user_dirs(home_dir_path, None, &bytes)
}

/// Returns a single XDG user directory obtained from $(XDG_CONFIG_HOME)/user-dirs.dirs.
pub fn single(home_dir_path: &Path, user_dir_file_path: &Path, user_dir_name: &str) -> HashMap<String, PathBuf> {
let bytes = read_all(user_dir_file_path).unwrap_or(Vec::new());
let bytes = read_all(user_dir_file_path).unwrap_or_default();
parse_user_dirs(home_dir_path, Some(user_dir_name), &bytes)
}

Expand Down
2 changes: 1 addition & 1 deletion src/lin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn home_dir() -> Option<PathBuf> { dirs_sys_next::home_dir() }
pub fn cache_dir() -> Option<PathBuf> { env::var_os("XDG_CACHE_HOME") .and_then(dirs_sys_next::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".cache"))) }
pub fn config_dir() -> Option<PathBuf> { env::var_os("XDG_CONFIG_HOME").and_then(dirs_sys_next::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".config"))) }
pub fn data_dir() -> Option<PathBuf> { env::var_os("XDG_DATA_HOME") .and_then(dirs_sys_next::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/share"))) }
pub fn data_local_dir() -> Option<PathBuf> { data_dir().clone() }
pub fn data_local_dir() -> Option<PathBuf> { data_dir() }
pub fn runtime_dir() -> Option<PathBuf> { env::var_os("XDG_RUNTIME_DIR").and_then(dirs_sys_next::is_absolute_path) }
pub fn executable_dir() -> Option<PathBuf> {
env::var_os("XDG_BIN_HOME").and_then(dirs_sys_next::is_absolute_path).or_else(|| {
Expand Down

0 comments on commit fc56545

Please sign in to comment.