#path #user #expand #attempt #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

#415 in Filesystem

Download history 584/week @ 2024-03-14 628/week @ 2024-03-21 619/week @ 2024-03-28 600/week @ 2024-04-04 1311/week @ 2024-04-11 902/week @ 2024-04-18 797/week @ 2024-04-25 611/week @ 2024-05-02 515/week @ 2024-05-09 616/week @ 2024-05-16 555/week @ 2024-05-23 617/week @ 2024-05-30 480/week @ 2024-06-06 1037/week @ 2024-06-13 920/week @ 2024-06-20 864/week @ 2024-06-27

3,461 downloads per month
Used in 14 crates (13 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