Skip to content

Commit

Permalink
Rollup merge of rust-lang#67233 - Luro02:cursor_traits, r=sfackler
Browse files Browse the repository at this point in the history
Add PartialEq and Eq to Cursor

closes rust-lang#67226
  • Loading branch information
Centril authored Dec 23, 2019
2 parents a916ac2 + 89986a3 commit 3278fc8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/libstd/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use core::convert::TryInto;
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Cursor<T> {
inner: T,
pos: u64,
Expand Down Expand Up @@ -942,4 +942,16 @@ mod tests {
c.set_position(<usize>::max_value() as u64 + 1);
assert!(c.write_all(&[1, 2, 3]).is_err());
}

#[test]
fn test_partial_eq() {
assert_eq!(Cursor::new(Vec::<u8>::new()), Cursor::new(Vec::<u8>::new()));
}

#[test]
fn test_eq() {
struct AssertEq<T: Eq>(pub T);

let _: AssertEq<Cursor<Vec<u8>>> = AssertEq(Cursor::new(Vec::new()));
}
}

0 comments on commit 3278fc8

Please sign in to comment.