Skip to content

Commit

Permalink
refactor(toml): Move accessor to be part of schema API
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 19, 2023
1 parent 512ce78 commit 7e4d0a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,13 +1568,6 @@ impl<T> schema::InheritableField<T> {
}),
}
}

fn as_value(&self) -> Option<&T> {
match self {
schema::InheritableField::Inherit(_) => None,
schema::InheritableField::Value(defined) => Some(defined),
}
}
}

impl schema::InheritableDependency {
Expand Down
9 changes: 9 additions & 0 deletions src/cargo/util/toml/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ pub enum InheritableField<T> {
Inherit(TomlInheritedField),
}

impl<T> InheritableField<T> {
pub fn as_value(&self) -> Option<&T> {
match self {
InheritableField::Inherit(_) => None,
InheritableField::Value(defined) => Some(defined),
}
}
}

//. This already has a `Deserialize` impl from version_trim_whitespace
pub type InheritableSemverVersion = InheritableField<semver::Version>;
impl<'de> de::Deserialize<'de> for InheritableSemverVersion {
Expand Down

0 comments on commit 7e4d0a6

Please sign in to comment.