Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Value == bool #138

Merged
merged 1 commit into from Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/value/partial_eq.rs
Expand Up @@ -98,6 +98,20 @@ impl PartialEq<Value> for String {
}
}

impl PartialEq<bool> 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)*) => {
$($(
Expand Down