#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

#402 in Filesystem

Download history 1265/week @ 2024-07-19 1294/week @ 2024-07-26 1811/week @ 2024-08-02 1615/week @ 2024-08-09 1161/week @ 2024-08-16 1022/week @ 2024-08-23 1234/week @ 2024-08-30 1354/week @ 2024-09-06 891/week @ 2024-09-13 1122/week @ 2024-09-20 1367/week @ 2024-09-27 1612/week @ 2024-10-04 1912/week @ 2024-10-11 1420/week @ 2024-10-18 1710/week @ 2024-10-25 1543/week @ 2024-11-01

7,047 downloads per month
Used in 20 crates (19 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.1MB
~21K SLoC