1 use std::path::PathBuf; 2 3 /// 获取给定路径的绝对路径 abs_path(path: &PathBuf) -> PathBuf4 pub fn abs_path(path: &PathBuf) -> PathBuf { 5 if path.is_absolute() { 6 path.to_path_buf() 7 } else { 8 std::env::current_dir().unwrap().join(path) 9 } 10 } 11