#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

#382 in Filesystem

Download history 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 1333/week @ 2024-11-28 1944/week @ 2024-12-05 1839/week @ 2024-12-12 1358/week @ 2024-12-19 1291/week @ 2024-12-26 3097/week @ 2025-01-02 2842/week @ 2025-01-09

8,966 downloads per month
Used in 26 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
~20K SLoC