use std::path::PathBuf;
pub(crate) trait AbsolutePath: Sized {
fn absolute(self) -> Self;
}
impl AbsolutePath for PathBuf {
fn absolute(self) -> Self {
std::path::absolute(&self)
.unwrap_or_else(|e| panic!("failed to get absolute path for `{}`: {e}", self.display()))
}
}
impl<T: AbsolutePath> AbsolutePath for Option<T> {
fn absolute(self) -> Self {
self.map(T::absolute)
}
}
impl<T: AbsolutePath> AbsolutePath for Vec<T> {
fn absolute(self) -> Self {
self.into_iter().map(T::absolute).collect()
}
}
macro_rules! impl_nop {
($($ty:path),* $(,)?) => {
$(
impl AbsolutePath for $ty {
fn absolute(self) -> Self {
self
}
}
)*
};
}
impl_nop! {
bool,
i8,
i16,
i32,
i64,
i128,
u8,
u16,
u32,
u64,
u128,
usize,
isize,
f32,
f64,
String,
anchor_client::Cluster,
crucible_fuzz_cli::Cli,
clap_complete::Shell,
solana_commitment_config::CommitmentLevel,
solana_pubkey::Pubkey,
}