Function git_url::expand_path::with

source ·
pub fn with(
    user: Option<&ForUser>,
    path: &BStr,
    home_for_user: impl FnOnce(&ForUser) -> Option<PathBuf>
) -> Result<PathBuf, Error>
Expand description

Expand path for the given user, which can be obtained by parse(), resolving them with home_for_user(&user).

For the common case consider using [expand_path()] instead.

Examples found in repository?
src/expand_path.rs (lines 121-126)
120
121
122
123
124
125
126
127
pub fn expand_path(user: Option<&ForUser>, path: &BStr) -> Result<PathBuf, Error> {
    with(user, path, |user| match user {
        ForUser::Current => home::home_dir(),
        ForUser::Name(user) => {
            home::home_dir().and_then(|home| home.parent().map(|home_dirs| home_dirs.join(user.to_string())))
        }
    })
}