diff --git a/parser/src/yaml.rs b/parser/src/yaml.rs index a6dc1f0..328775d 100644 --- a/parser/src/yaml.rs +++ b/parser/src/yaml.rs @@ -400,6 +400,16 @@ impl Yaml { this => this, } } + + /// See `or` for behavior. This performs the same operations, but with + /// borrowed values for less linear pipelines. + #[must_use] + pub fn borrowed_or<'a>(&'a self, other: &'a Self) -> &'a Self { + match self { + Yaml::BadValue | Yaml::Null => other, + this => this, + } + } } #[cfg_attr(feature = "cargo-clippy", allow(clippy::should_implement_trait))]