#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ManifestDependency {
pub manifest: String,
pub name: String,
pub section: String,
pub takes_from_workspace: bool,
}
impl ManifestDependency {
pub const SECTIONS: [&'static str; 3] =
["dependencies", "dev-dependencies", "build-dependencies"];
pub fn in_manifest(all: &Option<Vec<Self>>, manifest: &str) -> Option<Vec<Self>> {
Some(
all.as_ref()?
.iter()
.filter(|dependency| dependency.manifest == manifest)
.cloned()
.collect(),
)
}
pub fn new(manifest: &str, name: &str, section: &str, takes_from_workspace: bool) -> Self {
Self {
manifest: manifest.to_string(),
name: name.to_string(),
section: section.to_string(),
takes_from_workspace,
}
}
}