#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

#478 in Filesystem

Download history 529/week @ 2024-01-05 517/week @ 2024-01-12 475/week @ 2024-01-19 546/week @ 2024-01-26 405/week @ 2024-02-02 446/week @ 2024-02-09 476/week @ 2024-02-16 428/week @ 2024-02-23 417/week @ 2024-03-01 592/week @ 2024-03-08 571/week @ 2024-03-15 605/week @ 2024-03-22 649/week @ 2024-03-29 633/week @ 2024-04-05 1323/week @ 2024-04-12 751/week @ 2024-04-19

3,419 downloads per month
Used in 12 crates (11 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.3MB
~24K SLoC