Function shellexpand::tilde [] [src]

pub fn tilde<SI: ?Sized>(input: &SI) -> Cow<str> where
    SI: AsRef<str>, 

Performs the tilde expansion using the default system context.

This function delegates to tilde_with_context(), using the default system source of home directory path, namely std::env::home_dir() function.

Examples

use std::env;

let hds = env::home_dir()
    .map(|p| p.display().to_string())
    .unwrap_or_else(|| "~".to_owned());

assert_eq!(
    shellexpand::tilde("~/some/dir"),
    format!("{}/some/dir", hds)
);