mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
25 lines
491 B
Rust
25 lines
491 B
Rust
use std::path::PathBuf;
|
|
|
|
use allocative::Allocative;
|
|
use derive_deref::{Deref, DerefMut};
|
|
|
|
#[derive(Debug, Clone, Deref, DerefMut, Allocative)]
|
|
pub struct MapPath(PathBuf);
|
|
|
|
impl MapPath {
|
|
pub fn join(&self, path: &str) -> Self {
|
|
let path = path.replace(['-', '_', ' '], "/");
|
|
Self(self.0.join(path))
|
|
}
|
|
|
|
pub fn unwrap(&self) -> &PathBuf {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl From<PathBuf> for MapPath {
|
|
fn from(value: PathBuf) -> Self {
|
|
Self(value)
|
|
}
|
|
}
|