Add convenience PartialEq for BytesMut and Bytes (#141)

Saves the cognitive load of having to wrap them in slices to compare
them when that seems like what one would expect.

Signed-off-by: Clint Byrum <[email protected]>
This commit is contained in:
Clint Byrum
2017-06-30 20:33:01 -07:00
committed by Carl Lerche
parent 7ed78cef47
commit fb2d8cf1c0
2 changed files with 25 additions and 0 deletions
+11
View File
@@ -503,3 +503,14 @@ fn stress() {
assert_eq!(*buf, data[..]);
}
}
#[test]
fn partial_eq_bytesmut() {
let bytes = Bytes::from(&b"The quick red fox"[..]);
let bytesmut = BytesMut::from(&b"The quick red fox"[..]);
assert!(bytes == bytesmut);
assert!(bytesmut == bytes);
let bytes2 = Bytes::from(&b"Jumped over the lazy brown dog"[..]);
assert!(bytes2 != bytesmut);
assert!(bytesmut != bytes2);
}