#path #user #attempt #expand #os #expanding

expanduser

attempts to expand ~ and ~user while creating a filesystem path

5 stable releases

Uses old Rust 2015

1.2.2 Mar 25, 2021
1.2.1 Jul 11, 2018
1.1.0 Jul 11, 2018
1.0.0 Jun 5, 2018

#404 in Filesystem

Download history 1158/week @ 2024-08-15 1005/week @ 2024-08-22 1196/week @ 2024-08-29 1464/week @ 2024-09-05 949/week @ 2024-09-12 933/week @ 2024-09-19 1407/week @ 2024-09-26 1426/week @ 2024-10-03 2106/week @ 2024-10-10 1516/week @ 2024-10-17 1582/week @ 2024-10-24 1602/week @ 2024-10-31 1334/week @ 2024-11-07 1461/week @ 2024-11-14 1734/week @ 2024-11-21 870/week @ 2024-11-28

5,631 downloads per month
Used in 22 crates (21 directly)

CC-PDDC license

7KB
101 lines

expanduser

Similar to the python stdlib function os.path.expanduser, the function in this crate attempts to create a path while expanding ~ and ~user.

Installation

Add the following to your Cargo.toml:

expanduser = "1.2"

and add this to your crate root:

extern crate expanduser;

Usage

extern crate expanduser;

use std::io;
use expanduser::expanduser;

fn main() -> io::Result<()> {
    let path = expanduser("~/path/to/directory")?;
    assert_eq!(path.display().to_string(), "/home/foo/path/to/directory");
}

Dependencies

~0.3–1.2MB
~22K SLoC