path.rs
use std::path::{Path, PathBuf};
use crate::{Context, Localize};
use camino::{Utf8Path, Utf8PathBuf};
macro_rules! impl_std_path {
($path_type:ty) => {
impl Localize for $path_type {
fn localize(&self, _context: &Context, buffer: &mut String) {
buffer.push_str(self.to_string_lossy().as_ref());
}
}
};
}
macro_rules! impl_camino_path {
($path_type:ty) => {
impl Localize for $path_type {
fn localize(&self, _context: &Context, buffer: &mut String) {
buffer.push_str(self.as_str())
}
}
};
}
impl_std_path!(PathBuf);
impl_std_path!(Path);
impl_camino_path!(Utf8PathBuf);
impl_camino_path!(Utf8Path);