]> git.lizzy.rs Git - rust.git/commitdiff
Derive Clone + PartialEq + Eq for std::string::FromUtf8Error
authorkennytm <kennytm@gmail.com>
Sat, 1 Feb 2020 18:29:28 +0000 (02:29 +0800)
committerkennytm <kennytm@gmail.com>
Sat, 1 Feb 2020 18:29:28 +0000 (02:29 +0800)
src/liballoc/string.rs
src/liballoc/tests/string.rs

index 96f871d88970855d9cbf51f2ea6d86ad05b64a6a..8c9c95eec60c64f38ceb65a3d75fd42775c3c7a2 100644 (file)
@@ -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,
index dd44495845961dad751c59bba81bb1689b892abe..08859b2b24bde0b2c715cbb569f95ef1cd0c18e1 100644 (file)
@@ -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]