path_absolutize/absolutize.rs
1use std::{borrow::Cow, io, path::Path};
2
3/// Let `Path` and `PathBuf` have `absolutize` and `absolutize_virtually` method.
4pub trait Absolutize {
5 /// Get an absolute path. This works even if the path does not exist.
6 fn absolutize(&self) -> io::Result<Cow<Path>>;
7
8 /// Get an absolute path. This works even if the path does not exist. It gets the current working directory as the second argument.
9 fn absolutize_from(&self, cwd: impl AsRef<Path>) -> io::Result<Cow<Path>>;
10
11 /// Get an absolute path. This works even if the path does not exist.
12 fn absolutize_virtually(&self, virtual_root: impl AsRef<Path>) -> io::Result<Cow<Path>>;
13}