5 releases

0.1.4 Dec 26, 2024
0.1.3 Dec 26, 2024
0.1.2 Dec 25, 2024
0.1.1 Dec 25, 2024
0.1.0 Dec 25, 2024

#1212 in Rust patterns

Download history 55/week @ 2025-10-29 61/week @ 2025-11-05 82/week @ 2025-11-12 73/week @ 2025-11-19 56/week @ 2025-11-26 66/week @ 2025-12-03 50/week @ 2025-12-10 64/week @ 2025-12-17 67/week @ 2025-12-24 58/week @ 2025-12-31 36/week @ 2026-01-07 67/week @ 2026-01-14 83/week @ 2026-01-21 81/week @ 2026-01-28 68/week @ 2026-02-04 34/week @ 2026-02-11

280 downloads per month
Used in 20 crates (17 directly)

MIT license

9KB
143 lines

PathBufD

A wrapper of std::path::PathBuf that implements Display and simplifies usage by introducing a macro with a style similar to format! for interpolating paths.

Implements every (stable) API from PathBuf + some extras.

Usage

Creating a PathBufD in the current directory:

use pathbufd::{PathBufD, format_path};

fn main() {
    let buf = PathBufD::current();
    println!("path: {buf}")
}

Creating a PathBufD and pushing to it:

use pathbufd::{PathBufD};

fn main() {
    // create a new pathbuf
    let mut buf = PathBufD::new();

    // push to buf
    buf.push("directory");
    buf.push("file");

    // print result
    println!("path: {buf}")
}

Creating a PathBufD and joining to it:

use pathbufd::{PathBufD};

fn main() {
    // create a new pathbuf
    let buf = PathBufD::new().join("directory").join("file");

    // print result
    println!("path: {buf}")
}

Creating a PathBufD with a formatting macro:

use pathbufd::{PathBufD, format_path};

fn main() {
    let buf = path!("{}/file", "directory");
    println!("path: {buf}")
}

Extend a PathBufD with a slice of paths:

use pathbufd::{PathBufD, format_path};

fn main() {
    let buf = PathBufD::new().extend(["directory", "file"]);
    println!("path: {buf}")
}

Dependencies

~0.3–0.9MB
~20K SLoC