root

Function root 

Source
pub fn root() -> Result<PathBuf>
Expand description

Returns the absolute path to the Cargo workspace root.

Uses CARGO_MANIFEST_DIR, which Cargo sets to the xtask/ directory when building the xtask binary. The workspace root is one level up.

§Errors

Returns an error if the workspace root cannot be located (e.g. the binary is run outside the repository).

§Examples

// Note: requires running inside the Cadmus workspace.
let root = xtask_lib::tasks::util::workspace::root().unwrap();
assert!(root.join("Cargo.toml").exists());