Skip to content

Commit 6ab22e3

Browse files
authored
add into_value utility function for inheritableField (#16234)
This PR is for making transformations of this data type easier to express, as an addition to #15828
2 parents af465ec + ee839cb commit 6ab22e3

File tree

1 file changed

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

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ impl<T> InheritableField<T> {
352352
}
353353
}
354354

355+
pub fn into_value(self) -> Option<T> {
356+
match self {
357+
Self::Inherit(_) => None,
358+
Self::Value(defined) => Some(defined),
359+
}
360+
}
361+
355362
pub fn is_inherited(&self) -> bool {
356363
matches!(self, Self::Inherit(_))
357364
}

0 commit comments

Comments
 (0)