#path #traits #extension #methods #path-buf #convenience #str

pathext

A small path trait extension with some convenience methods

7 releases

0.2.1 Feb 17, 2024
0.2.0 Feb 17, 2024
0.1.6 Jun 7, 2022
0.1.5 May 17, 2022
0.1.4 Jan 24, 2022

#1011 in Rust patterns

Download history 152/week @ 2024-02-12 117/week @ 2024-02-19 35/week @ 2024-02-26 8/week @ 2024-03-11 1/week @ 2024-03-18 99/week @ 2024-04-01

108 downloads per month

MIT/Apache

12KB
173 lines

PathExt

A small collection of utilities on Path and PathBuf, technically AsRef<Path> which includes &str.

Simple usage

use pathext::PathExt;
use std::ops::Not;
use std::path::Path;

// Because of this expectation breaking difference:
assert!("archive.tar.gz").ends_with(".tar.gz"));
assert!(Path::new("archive.tar.gz").ends_with(".tar.gz").not());
// Instead use:
assert!("archive.tar.gz").ends_with_extentions(".tar.gz"));
assert!(Path::new()"archive.tar.gz")).ends_with_extentions(".tar.gz"));

// Plus some more utility
assert!("/some/path".has_component("path"));
assert!("multiple-extensions.tar.gz".strip_extensions(), Some("multiple-extensions"));

lib.rs:

pathext

A simple extension trait that includes some convenience methods I have found useful.

No runtime deps