#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

#359 in Filesystem

Download history 1521/week @ 2024-11-16 1430/week @ 2024-11-23 1710/week @ 2024-11-30 1875/week @ 2024-12-07 1750/week @ 2024-12-14 1259/week @ 2024-12-21 1718/week @ 2024-12-28 3455/week @ 2025-01-04 3806/week @ 2025-01-11 3521/week @ 2025-01-18 4575/week @ 2025-01-25 9456/week @ 2025-02-01 14690/week @ 2025-02-08 20461/week @ 2025-02-15 9928/week @ 2025-02-22 11220/week @ 2025-03-01

58,716 downloads per month
Used in 27 crates (25 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