Skip to main content

expand_tilde

Function expand_tilde 

Source
pub fn expand_tilde(s: &str) -> Utf8PathBuf
Expand description

Expand a leading ~ or ~/... to the user’s home directory.

Smooths over the $HOME (Unix) vs $USERPROFILE (Windows) split so dst = "~/.config" works on every platform without writing a Tera env(...) call. Home is resolved via home_dir.

~user (other-user homes) is left untouched — we don’t support that form. If $HOME / $USERPROFILE are both unset the input is also returned verbatim (better to surface a “no such path” error later than silently substitute an empty string).