Coverage Report

Created: 2025-10-31 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/reqsign-0.16.5/src/dirs.rs
Line
Count
Source
1
//! Directory related utils.
2
3
/// Expand `~` in input path.
4
///
5
/// - If path not starts with `~/` or `~\\`, returns `Some(path)` directly.
6
/// - Otherwise, replace `~` with home dir instead.
7
/// - If home_dir is not found, returns `None`.
8
#[cfg(not(target_arch = "wasm32"))]
9
0
pub fn expand_homedir(path: &str) -> Option<String> {
10
0
    if !path.starts_with("~/") && !path.starts_with("~\\") {
11
0
        Some(path.to_string())
12
    } else {
13
0
        home::home_dir().map(|home| path.replace('~', &home.to_string_lossy()))
14
    }
15
0
}