From 3177d4a6fc8226fa3fdfef656f934db0b75db541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Thu, 1 Feb 2024 18:32:20 +0100 Subject: [PATCH] update serde_yaml to 0.9 --- Cargo.toml | 3 +-- src/value/serde_yaml.rs | 19 ++++++++++++------- src/value/yaml_rust.rs | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ac3881b..b154b5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ include = ["src/**/*", "LICENSE-*", "README.md", "CHANGELOG.md"] [dependencies] rustc-serialize = {version = "0.3.24", optional = true} serde_json = {version = "1.0.45", optional = true} -serde_yaml = {version = "0.8", optional = true} +serde_yaml = {version = "0.9", optional = true} yaml-rust = {version = "0.4", optional = true} [dev-dependencies] @@ -26,4 +26,3 @@ with-rustc-serialize = ["rustc-serialize"] with-serde-json = ["serde_json"] with-serde-yaml = ["serde_yaml"] with-yaml-rust = ["yaml-rust"] - diff --git a/src/value/serde_yaml.rs b/src/value/serde_yaml.rs index 1edd8ba..41e0eae 100644 --- a/src/value/serde_yaml.rs +++ b/src/value/serde_yaml.rs @@ -12,16 +12,19 @@ impl Value for SerdeYaml { type Item = SerdeYaml; fn items<'a>(&'a self) -> Option + 'a>> { match *self { - SerdeYaml::String(_) | SerdeYaml::Number(_) | SerdeYaml::Bool(_) | SerdeYaml::Null => { - None - } + SerdeYaml::String(_) + | SerdeYaml::Number(_) + | SerdeYaml::Bool(_) + | SerdeYaml::Null + | SerdeYaml::Tagged(_) => None, SerdeYaml::Sequence(ref inner) => Some(Box::new( inner.iter().enumerate().map(|(i, v)| (Key::Index(i), v)), )), SerdeYaml::Mapping(ref inner) => Some(Box::new(inner.iter().map(|(k, v)| { ( Key::String( - to_string(k).expect("yaml value to serialize into yaml correctly")[4..] + to_string(k) + .expect("yaml value to serialize into yaml correctly") .to_owned(), ), v, @@ -69,7 +72,7 @@ impl Mutable for SerdeYaml { array[target_index] = value; } &mut array[target_index] - }; + } for (i, k) in keys.iter().enumerate() { c = match *k { Key::String(ref k) => { @@ -92,7 +95,8 @@ impl Mutable for SerdeYaml { | c @ &mut SerdeYaml::Number(_) | c @ &mut SerdeYaml::Bool(_) | c @ &mut SerdeYaml::Null - | c @ &mut SerdeYaml::Sequence(_) => { + | c @ &mut SerdeYaml::Sequence(_) + | c @ &mut SerdeYaml::Tagged(_) => { drop(mem::replace( c, SerdeYaml::Mapping({ @@ -121,7 +125,8 @@ impl Mutable for SerdeYaml { | c @ &mut SerdeYaml::Number(_) | c @ &mut SerdeYaml::Bool(_) | c @ &mut SerdeYaml::Null - | c @ &mut SerdeYaml::Mapping(_) => { + | c @ &mut SerdeYaml::Mapping(_) + | c @ &mut SerdeYaml::Tagged(_) => { let mut a = Vec::new(); runup_array_or_value(&mut a, idx, i, last_key_index, v); drop(mem::replace(c, SerdeYaml::Sequence(a))); diff --git a/src/value/yaml_rust.rs b/src/value/yaml_rust.rs index 5912c25..f9f693e 100644 --- a/src/value/yaml_rust.rs +++ b/src/value/yaml_rust.rs @@ -82,7 +82,7 @@ impl Mutable for Yaml { array[target_index] = value; } &mut array[target_index] - }; + } for (i, k) in keys.iter().enumerate() { c = match *k { Key::String(ref k) => {