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.
This commit is contained in:
Weihang Lo 2025-08-12 17:15:43 +00:00 committed by GitHub
commit 6bf996c866
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -351,6 +351,10 @@ impl<T> InheritableField<T> {
InheritableField::Value(defined) => Some(defined),
}
}
pub fn is_inherited(&self) -> bool {
matches!(self, Self::Inherit(_))
}
}
//. This already has a `Deserialize` impl from version_trim_whitespace
@ -675,6 +679,10 @@ impl InheritableDependency {
InheritableDependency::Inherit(_) => Err(UnresolvedError),
}
}
pub fn is_inherited(&self) -> bool {
matches!(self, InheritableDependency::Inherit(_))
}
}
impl<'de> de::Deserialize<'de> for InheritableDependency {