Skip to content

Instantly share code, notes, and snippets.

View NotNorom's full-sized avatar
👀
👀

Andre Julius NotNorom

👀
👀
View GitHub Profile
@NotNorom
NotNorom / merge_yaml.rs
Created March 27, 2024 12:53 — forked from decatur/merge_yaml.rs
rust merge multiple yaml docs
// See https://stackoverflow.com/questions/67727239/how-to-combine-including-nested-array-values-two-serde-yamlvalue-objects
// Note this is not https://docs.rs/serde_yaml/latest/serde_yaml/value/enum.Value.html#method.apply_merge
use serde::{Serialize, Deserialize};
use serde_yaml::Value;
fn merge_yaml(a: &mut serde_yaml::Value, b: serde_yaml::Value) {
match (a, b) {
(a @ &mut serde_yaml::Value::Mapping(_), serde_yaml::Value::Mapping(b)) => {
let a = a.as_mapping_mut().unwrap();