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

Commit

Permalink
Merge pull request #138 from CAD97/patch-1
Browse files Browse the repository at this point in the history
Value == bool
  • Loading branch information
dtolnay committed Oct 4, 2019
2 parents 4428cac + 4c8c5bd commit 5f25a69
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit 5f25a69

Please sign in to comment.