Skip to content

Commit cb5a4d1

Browse files
committed
Use ToString specialization macro also for Cow and String
1 parent 6a24ae9 commit cb5a4d1

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

library/alloc/src/string.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,6 +2966,8 @@ macro_rules! to_string_str {
29662966

29672967
#[cfg(not(no_global_oom_handling))]
29682968
to_string_str! {
2969+
Cow<'_, str>,
2970+
String,
29692971
// Generic/generated code can sometimes have multiple, nested references
29702972
// for strings, including `&&&str`s that would never be written
29712973
// by hand.
@@ -2984,22 +2986,6 @@ to_string_str! {
29842986
str,
29852987
}
29862988

2987-
#[cfg(not(no_global_oom_handling))]
2988-
impl SpecToString for Cow<'_, str> {
2989-
#[inline]
2990-
fn spec_to_string(&self) -> String {
2991-
self[..].to_owned()
2992-
}
2993-
}
2994-
2995-
#[cfg(not(no_global_oom_handling))]
2996-
impl SpecToString for String {
2997-
#[inline]
2998-
fn spec_to_string(&self) -> String {
2999-
self.to_owned()
3000-
}
3001-
}
3002-
30032989
#[cfg(not(no_global_oom_handling))]
30042990
impl SpecToString for fmt::Arguments<'_> {
30052991
#[inline]

0 commit comments

Comments
 (0)