#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

#372 in Filesystem

Download history 1507/week @ 2024-10-27 1564/week @ 2024-11-03 1368/week @ 2024-11-10 1625/week @ 2024-11-17 1288/week @ 2024-11-24 1754/week @ 2024-12-01 1883/week @ 2024-12-08 1707/week @ 2024-12-15 1364/week @ 2024-12-22 1772/week @ 2024-12-29 3494/week @ 2025-01-05 3802/week @ 2025-01-12 3668/week @ 2025-01-19 4409/week @ 2025-01-26 11326/week @ 2025-02-02 12991/week @ 2025-02-09

32,673 downloads per month
Used in 24 crates (23 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
~20K SLoC