1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use std::path::PathBuf;

fn parse_tilde(path: &str) -> String {
    let path = tilde_expand::tilde_expand(path.as_bytes());
    String::from_utf8(path).unwrap()
}


pub trait PathExpandUser {
    fn expanduser(&mut self);
}

impl PathExpandUser for PathBuf {
    fn expanduser(&mut self) {
        let path = tilde_expand::tilde_expand(self.to_str().unwrap().as_bytes());
        let path = String::from_utf8(path).unwrap();
        let path = Self::from(path);
        *self = path;
    }
}