about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2025-08-18 11:51:31 +0200
committerTobias Bucher <tobiasbucher5991@gmail.com>2025-08-19 17:35:56 +0200
commitcb5a4d138a298853225d7561c243ce6e23064775 (patch)
tree4f0b3b20355ad1af58e91f2d63c9504c613fed6d
parent6a24ae96eaf175b048e70dfb46dfb860ee7147d9 (diff)
downloadrust-cb5a4d138a298853225d7561c243ce6e23064775.tar.gz
rust-cb5a4d138a298853225d7561c243ce6e23064775.zip
Use `ToString` specialization macro also for `Cow` and `String`
-rw-r--r--library/alloc/src/string.rs18
1 files changed, 2 insertions, 16 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index b1f2cb598c8..ec4d934a5a3 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -2966,6 +2966,8 @@ macro_rules! to_string_str {
 
 #[cfg(not(no_global_oom_handling))]
 to_string_str! {
+    Cow<'_, str>,
+    String,
     // Generic/generated code can sometimes have multiple, nested references
     // for strings, including `&&&str`s that would never be written
     // by hand.
@@ -2985,22 +2987,6 @@ to_string_str! {
 }
 
 #[cfg(not(no_global_oom_handling))]
-impl SpecToString for Cow<'_, str> {
-    #[inline]
-    fn spec_to_string(&self) -> String {
-        self[..].to_owned()
-    }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl SpecToString for String {
-    #[inline]
-    fn spec_to_string(&self) -> String {
-        self.to_owned()
-    }
-}
-
-#[cfg(not(no_global_oom_handling))]
 impl SpecToString for fmt::Arguments<'_> {
     #[inline]
     fn spec_to_string(&self) -> String {