Merge pull request #338 from foriequal0/master

Implement PartialEq for bool
This commit is contained in:
David Tolnay 2017-07-13 22:10:40 -07:00 committed by GitHub
commit eb6067fbcd
2 changed files with 13 additions and 0 deletions

View File

@ -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
}

View File

@ -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 {