1
Fork 0

Simplify RelPath implementation

This commit is contained in:
bjorn3 2024-12-18 18:11:47 +00:00
parent a220a53af3
commit 8521e70019

View file

@ -11,20 +11,11 @@ pub(crate) struct Dirs {
#[doc(hidden)] #[doc(hidden)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub(crate) enum PathBase { enum PathBase {
Source, Source,
Build, Build,
} }
impl PathBase {
fn to_path(self, dirs: &Dirs) -> PathBuf {
match self {
PathBase::Source => dirs.source_dir.clone(),
PathBase::Build => dirs.build_dir.clone(),
}
}
}
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub(crate) struct RelPath { pub(crate) struct RelPath {
base: PathBase, base: PathBase,
@ -41,6 +32,9 @@ impl RelPath {
} }
pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf { pub(crate) fn to_path(&self, dirs: &Dirs) -> PathBuf {
self.base.to_path(dirs).join(self.suffix) match self.base {
PathBase::Source => dirs.source_dir.join(self.suffix),
PathBase::Build => dirs.build_dir.join(self.suffix),
}
} }
} }