git-next/crates/config/src/git_dir.rs

30 lines
626 B
Rust
Raw Normal View History

2024-06-16 08:00:43 +01:00
//
use std::path::PathBuf;
2024-06-16 08:00:43 +01:00
crate::newtype!(GitDir is a PathBuf, without Display);
impl GitDir {
pub const fn pathbuf(&self) -> &PathBuf {
&self.0
}
}
impl std::fmt::Display for GitDir {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", &self.0.display())
}
}
impl From<&str> for GitDir {
fn from(value: &str) -> Self {
Self(value.into())
}
}
impl From<&GitDir> for PathBuf {
fn from(value: &GitDir) -> Self {
value.to_path_buf()
}
}
impl From<GitDir> for PathBuf {
fn from(value: GitDir) -> Self {
value.0
}
}