Rollup merge of #68738 - kennytm:derive-clone-eq-for-fromutf8error, r=sfackler
Derive Clone + Eq for std::string::FromUtf8Error Implement `Clone` and `Eq` for `std::string::FromUtf8Error`. Both the inner `Vec<u8>` and `std::str::Utf8Error` are also `Clone + Eq`, so I don't see why we shouldn't derive them on `FromUtf8Error` as well. (impl are insta-stable, requiring FCP from T-libs.)
This commit is contained in:
commit
0b50319af6
@ -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,
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user