diff options
| -rw-r--r-- | src/liballoc/string.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/tests/string.rs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 96f871d8897..8c9c95eec60 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -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, diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index dd444958459..08859b2b24b 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -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] |
