Skip to content

Commit

Permalink
Implement PartialEq<bool> for Value
Browse files Browse the repository at this point in the history
  • Loading branch information
foriequal0 committed Jul 12, 2017
1 parent 58a7642 commit 7fbf18e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/value/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ partialeq_numeric! {
[i8 i16 i32 i64 isize], as_i64, i64
[u8 u16 u32 u64 usize], as_u64, u64
[f32 f64], as_f64, f64
[bool], as_bool, bool
}
12 changes: 12 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,18 @@ fn test_partialeq_string() {
assert_eq!(String::from("42"), v);
}

#[test]
fn test_partialeq_bool() {
let v = to_value(true).unwrap();
assert_eq!(v, true);
assert_eq!(true, v);
assert_ne!(v, false);
assert_ne!(v, "true");
assert_ne!(v, 1);
assert_ne!(v, 0);
}


struct FailReader(io::ErrorKind);

impl io::Read for FailReader {
Expand Down

0 comments on commit 7fbf18e

Please sign in to comment.