ai/style.rs
1use std::env;
2use std::path::PathBuf;
3pub trait Styled {
4 fn relative_path(&self) -> PathBuf;
5}
6
7impl Styled for PathBuf {
8 fn relative_path(&self) -> PathBuf {
9 let current_dir = env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
10 let relative_path = self.strip_prefix(¤t_dir).unwrap_or(self.as_path());
11 relative_path.to_path_buf()
12 }
13}