Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update serde_yaml to 0.9 #13

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -26,4 +26,3 @@ with-rustc-serialize = ["rustc-serialize"]
with-serde-json = ["serde_json"]
with-serde-yaml = ["serde_yaml"]
with-yaml-rust = ["yaml-rust"]

19 changes: 12 additions & 7 deletions src/value/serde_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ impl Value for SerdeYaml {
type Item = SerdeYaml;
fn items<'a>(&'a self) -> Option<Box<dyn Iterator<Item = (Self::Key, &'a Self::Item)> + '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,
Expand Down Expand Up @@ -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) => {
Expand All @@ -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({
Expand Down Expand Up @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion src/value/yaml_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Loading