#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

#8 in #attempt

Download history 449/week @ 2024-02-26 451/week @ 2024-03-04 582/week @ 2024-03-11 616/week @ 2024-03-18 580/week @ 2024-03-25 688/week @ 2024-04-01 602/week @ 2024-04-08 1524/week @ 2024-04-15 718/week @ 2024-04-22 821/week @ 2024-04-29 449/week @ 2024-05-06 609/week @ 2024-05-13 635/week @ 2024-05-20 487/week @ 2024-05-27 628/week @ 2024-06-03 669/week @ 2024-06-10

2,484 downloads per month
Used in 13 crates (12 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.4–1.2MB
~23K SLoC