pub struct PackageIndex { /* private fields */ }Expand description
Every package a workspace contains, indexed by the directory its manifest lives in.
Implementations§
Source§impl PackageIndex
impl PackageIndex
Sourcepub fn package_at(&self, source_path: &str) -> Option<(&str, &str)>
pub fn package_at(&self, source_path: &str) -> Option<(&str, &str)>
The package a source path belongs to, by longest-prefix match on the manifest directories.
let metadata = r#"{"workspace_root":"/w","packages":[
{"name":"app","version":"0.1.0","manifest_path":"/w/app/Cargo.toml"},
{"name":"leaf","version":"0.1.0","manifest_path":"/w/leaf/Cargo.toml"}]}"#;
let index = parse_cargo_metadata(metadata)?;
assert_eq!(index.package_at("app/src/main.rs"), Some(("app", "0.1.0")));
assert_eq!(index.package_at("/w/leaf/build.rs"), Some(("leaf", "0.1.0")));
assert_eq!(index.package_at("elsewhere/src/lib.rs"), None);
assert_eq!(index.package_at(""), None);Trait Implementations§
Source§impl Clone for PackageIndex
impl Clone for PackageIndex
Source§impl Debug for PackageIndex
impl Debug for PackageIndex
impl Eq for PackageIndex
Source§impl PartialEq for PackageIndex
impl PartialEq for PackageIndex
impl StructuralPartialEq for PackageIndex
Auto Trait Implementations§
impl Freeze for PackageIndex
impl RefUnwindSafe for PackageIndex
impl Send for PackageIndex
impl Sync for PackageIndex
impl Unpin for PackageIndex
impl UnsafeUnpin for PackageIndex
impl UnwindSafe for PackageIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more