Skip to content

Commit

Permalink
Derive Clone + PartialEq + Eq for std::string::FromUtf8Error
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Feb 1, 2020
1 parent 6c0b779 commit 847d5b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Expand Up @@ -319,7 +319,7 @@ pub struct String {
/// assert_eq!(vec![0, 159], value.unwrap_err().into_bytes());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FromUtf8Error {
bytes: Vec<u8>,
error: Utf8Error,
Expand Down
4 changes: 4 additions & 0 deletions src/liballoc/tests/string.rs
Expand Up @@ -50,7 +50,11 @@ fn test_from_utf8() {

let xs = b"hello\xFF".to_vec();
let err = String::from_utf8(xs).unwrap_err();
assert_eq!(err.as_bytes(), b"hello\xff");
let err_clone = err.clone();
assert_eq!(err, err_clone);
assert_eq!(err.into_bytes(), b"hello\xff".to_vec());
assert_eq!(err_clone.utf8_error().valid_up_to(), 5);
}

#[test]
Expand Down

0 comments on commit 847d5b4

Please sign in to comment.