pub fn home_to_tilde(path: impl AsRef<Path>) -> PathBuf {
    let path = path.as_ref();
    match path.strip_prefix(home_dir()) {
        Ok(relative_path) => PathBuf::from("~").join(relative_path),
        // The home directory isn't a prefix of `path` - just return `path` unchanged
        Err(_) => PathBuf::from(path),
    }
}
/// If `path` begins with the absolute path of the home directory, replaces it
/// with a tilde. If `path` doesn't start with the absolute path of the home
/// directory, just returns `path`.
If `path` begins with the absolute path of the home directory, replaces it
with a tilde. If `path` doesn't start with the absolute path of the home
directory, just returns `path`.
If ` path ` begins with the absolute path of the home directory replaces it with a tilde . If ` path ` doesn ' t start with the absolute path of the home directory just returns ` path ` .
pub fn home_to_tilde(path: impl AsRef<Path>) -> PathBuf {
    let path = path.as_ref();
    match path.strip_prefix(home_dir()) {
        Ok(relative_path) => PathBuf::from("~").join(relative_path),
        // The home directory isn't a prefix of `path` - just return `path` unchanged
        Err(_) => PathBuf::from(path),
    }
}
pub fn home_to_tilde ( path : impl AsRef < Path > ) -> PathBuf { let path = path . as_ref ( ) ; match path . strip_prefix ( home_dir ( ) ) { Ok ( relative_path ) => PathBuf :: from ( " " ) . join ( relative_path ) , // The home directory isn't a prefix of `path` - just return `path` unchanged Err ( _ ) => PathBuf :: from ( path ) , } }
If `path` begins with the absolute path of the home directory, replaces it
with a tilde.
If ` path ` begins with the absolute path of the home directory replaces it with a tilde .
path
impl AsRef<Path>
path
impl AsRef<Path>