Skip to content

Commit 13255d0

Browse files
committed
fix(schemas): Support deserializing str's as well as Strings
Not needed for `toml` but could be useful for other formats.
1 parent fbc8ba8 commit 13255d0

File tree

1 file changed

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

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ impl<'de> de::Deserialize<'de> for InheritableString {
418418
Ok(InheritableString::Value(value))
419419
}
420420

421+
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
422+
where
423+
E: de::Error,
424+
{
425+
self.visit_string(value.to_owned())
426+
}
427+
421428
fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
422429
where
423430
V: de::MapAccess<'de>,
@@ -454,6 +461,13 @@ impl<'de> de::Deserialize<'de> for InheritableRustVersion {
454461
Ok(InheritableRustVersion::Value(value))
455462
}
456463

464+
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
465+
where
466+
E: de::Error,
467+
{
468+
self.visit_string(value.to_owned())
469+
}
470+
457471
fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
458472
where
459473
V: de::MapAccess<'de>,
@@ -533,6 +547,13 @@ impl<'de> de::Deserialize<'de> for InheritableStringOrBool {
533547
StringOrBool::deserialize(string).map(InheritableField::Value)
534548
}
535549

550+
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
551+
where
552+
E: de::Error,
553+
{
554+
self.visit_string(value.to_owned())
555+
}
556+
536557
fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
537558
where
538559
V: de::MapAccess<'de>,

0 commit comments

Comments
 (0)