Skip to content

Commit 3278fc8

Browse files
authored
Rollup merge of rust-lang#67233 - Luro02:cursor_traits, r=sfackler
Add PartialEq and Eq to Cursor closes rust-lang#67226
2 parents a916ac2 + 89986a3 commit 3278fc8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/libstd/io/cursor.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use core::convert::TryInto;
7272
/// }
7373
/// ```
7474
#[stable(feature = "rust1", since = "1.0.0")]
75-
#[derive(Clone, Debug, Default)]
75+
#[derive(Clone, Debug, Default, Eq, PartialEq)]
7676
pub struct Cursor<T> {
7777
inner: T,
7878
pos: u64,
@@ -942,4 +942,16 @@ mod tests {
942942
c.set_position(<usize>::max_value() as u64 + 1);
943943
assert!(c.write_all(&[1, 2, 3]).is_err());
944944
}
945+
946+
#[test]
947+
fn test_partial_eq() {
948+
assert_eq!(Cursor::new(Vec::<u8>::new()), Cursor::new(Vec::<u8>::new()));
949+
}
950+
951+
#[test]
952+
fn test_eq() {
953+
struct AssertEq<T: Eq>(pub T);
954+
955+
let _: AssertEq<Cursor<Vec<u8>>> = AssertEq(Cursor::new(Vec::new()));
956+
}
945957
}

0 commit comments

Comments
 (0)