pathbufd

Crates.iopathbufd
lib.rspathbufd
version0.1.4
created_at2024-12-25 20:57:42.956705+00
updated_at2024-12-26 19:21:04.640166+00
descriptionPathBuf with Display + formatting macro
homepage
repositoryhttps://github.com/trisuaso/pathbufd
max_upload_size
id1495215
size10,035
maxwell (caffeineee)

documentation

README

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}")
}
Commit count: 7

cargo fmt