diff options
| author | bors <bors@rust-lang.org> | 2020-02-09 18:44:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-09 18:44:39 +0000 |
| commit | 71c7e149e42cb0fc78a80db70d2525973311d488 (patch) | |
| tree | 2ae0b4581137453b4199f5d34bcff5c3c91413fc /src/liballoc | |
| parent | 1ad6b5e1e69ad3d3509abd8c041bb9fb2dd86c41 (diff) | |
| parent | da005822cef776e9757127ce0e609e9c3a737b39 (diff) | |
| download | rust-71c7e149e42cb0fc78a80db70d2525973311d488.tar.gz rust-71c7e149e42cb0fc78a80db70d2525973311d488.zip | |
Auto merge of #69004 - jonas-schievink:rollup-z2ymler, r=jonas-schievink
Rollup of 5 pull requests Successful merges: - #68738 (Derive Clone + Eq for std::string::FromUtf8Error) - #68742 (implement AsMut<str> for String) - #68881 (rustc_codegen_llvm: always set AlwaysPreserve on all debuginfo variables) - #68911 (Speed up the inherent impl overlap check) - #68913 (Pretty-print generic params and where clauses on associated types) Failed merges: r? @ghost
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/string.rs | 10 | ||||
| -rw-r--r-- | src/liballoc/tests/string.rs | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 96f871d8897..3cb1f259a0b 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, @@ -2208,6 +2208,14 @@ impl AsRef<str> for String { } } +#[stable(feature = "string_as_mut", since = "1.43.0")] +impl AsMut<str> for String { + #[inline] + fn as_mut(&mut self) -> &mut str { + self + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<[u8]> for String { #[inline] 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] |
