#path #expand #user #fn #extern #stdlib #create #python #display #home

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

#531 in Filesystem

Download history 1422/week @ 2023-02-11 1335/week @ 2023-02-18 951/week @ 2023-02-25 986/week @ 2023-03-04 538/week @ 2023-03-11 227/week @ 2023-03-18 597/week @ 2023-03-25 444/week @ 2023-04-01 564/week @ 2023-04-08 508/week @ 2023-04-15 391/week @ 2023-04-22 635/week @ 2023-04-29 305/week @ 2023-05-06 409/week @ 2023-05-13 321/week @ 2023-05-20 282/week @ 2023-05-27

1,374 downloads per month
Used in 5 crates

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.5–1MB
~25K SLoC