inline-xml 0.3.2

Embed XML data directly in your Rust code
Documentation
use crate::*;

impl Tag {
    fn flattened(self) -> Self {
        Self {
            inner: self.inner.map(|x| x.flattened()),
            ..self
        }
    }
}

impl Content {
    fn unwrap(self) -> Vec<Content> {
        match self {
            Self::Nested(x) => x.flattened().0,
            Self::Tag(t)    => vec![Self::Tag(t.flattened())],
            c               => vec![c],
        }
    }
}

impl Xml {
    pub fn flattened(self) -> Self {
        let inner = self
            .0
            .into_iter()
            .map(Content::unwrap)
            .flatten()
            .collect();
        Self(inner)
    }
}