From 4c8c5bd090455629e00e2c3e6571b9ee08819cb2 Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Thu, 3 Oct 2019 11:01:40 -0400 Subject: [PATCH] Value == bool --- src/value/partial_eq.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/value/partial_eq.rs b/src/value/partial_eq.rs index f0d62a51..f01c26e6 100644 --- a/src/value/partial_eq.rs +++ b/src/value/partial_eq.rs @@ -98,6 +98,20 @@ impl PartialEq for String { } } +impl PartialEq for Value { + /// Compare YAML value with bool + /// + /// # Examples + /// + /// ```edition2018 + /// # use serde_yaml::Value; + /// assert!(Value::Bool(true) == true); + /// ``` + fn eq(&self, other: &bool) -> bool { + self.as_bool().map_or(false, |b| b == *other) + } +} + macro_rules! partialeq_numeric { ($([$($ty:ty)*], $conversion:ident, $base:ty)*) => { $($(