Skip to main content

expand_tilde

Function expand_tilde 

Source
pub fn expand_tilde(raw: &str) -> String
Expand description

Expand a leading ~ against the user’s home directory.

~ alone and ~/rest both expand; ~user does not (there is no lookup for another user’s home that works across platforms). Anything else is returned unchanged, so this is safe to call on a path that is already absolute.

Unresolvable home → the input, verbatim. That keeps the failure visible as a path with a ~ still in it rather than as a silently-wrong location.