Skip to content

Commit 6bf996c

Browse files
authored
add is_inherited methods to InheritableDependency and InheritableField (#15828)
I was looking into adding cargo_util_schemas as a parsing backend for crates-io and this was a little method I found myself missing a lot.
2 parents c710fc0 + 6d3ff14 commit 6bf996c

File tree

1 file changed

+8
-0
lines changed
  • crates/cargo-util-schemas/src/manifest

1 file changed

+8
-0
lines changed

crates/cargo-util-schemas/src/manifest/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ impl<T> InheritableField<T> {
351351
InheritableField::Value(defined) => Some(defined),
352352
}
353353
}
354+
355+
pub fn is_inherited(&self) -> bool {
356+
matches!(self, Self::Inherit(_))
357+
}
354358
}
355359

356360
//. This already has a `Deserialize` impl from version_trim_whitespace
@@ -675,6 +679,10 @@ impl InheritableDependency {
675679
InheritableDependency::Inherit(_) => Err(UnresolvedError),
676680
}
677681
}
682+
683+
pub fn is_inherited(&self) -> bool {
684+
matches!(self, InheritableDependency::Inherit(_))
685+
}
678686
}
679687

680688
impl<'de> de::Deserialize<'de> for InheritableDependency {

0 commit comments

Comments
 (0)