| Crates.io | dirge |
| lib.rs | dirge |
| version | 0.1.3 |
| created_at | 2025-06-24 08:15:05.255648+00 |
| updated_at | 2025-07-27 08:21:25.396053+00 |
| description | Convenient extensions to the standard library's path types |
| homepage | |
| repository | https://github.com/daniel-levin/dirge |
| max_upload_size | |
| id | 1723994 |
| size | 42,017 |
use dirge::{AbsPath, AbsPathBuf};
use std::path::Path;
let a: AbsPathBuf = example();
let b: &AbsPath = &a;
let c: &Path = &a;
let d: &Path = &b;
/// Precondition enforced by type system
fn needs_abs_path(p: &AbsPath) {
}
/// But they go anywhere the standard library's paths do!
let _ = std::fs::read_to_string(&a);
use dirge::{RelPath, RelPathBuf};
use std::path::Path;
let rel = RelPathBuf::new("src/main.rs").unwrap();
let rel_ref: &RelPath = &rel;
let path_ref: &Path = &rel;
/// Type system enforces relative path requirement
fn needs_relative_path(p: &RelPath) {
}
needs_relative_path(&rel);
use dirge::{NormPath, NormPathBuf};
use std::path::Path;
let norm = NormPathBuf::new("path/./to/../file.txt").unwrap();
assert_eq!(norm.to_string_lossy(), "path/file.txt");
let norm_ref: &NormPath = &norm;
let path_ref: &Path = &norm;
/// Type system guarantees normalized paths
fn needs_normalized_path(p: &NormPath) {
}
needs_normalized_path(&norm);
This crate provides portable extensions to the standard library's path functionality. Our types have specific usages while incurring no storage overhead. For example, [AbsPathBuf] and [std::path::PathBuf] have identical in-memory representations, but the former is guaranteed to be an absolute path.
This crate has several goals:
License: Unlicense/MIT