@@ -2939,68 +2939,41 @@ impl SpecToString for i8 {
2939
2939
}
2940
2940
}
2941
2941
2942
- // Generic/generated code can sometimes have multiple, nested references
2943
- // for strings, including `&&&str`s that would never be written
2944
- // by hand. This macro generates twelve layers of nested `&`-impl
2945
- // for primitive strings.
2946
- #[ cfg( not( no_global_oom_handling) ) ]
2947
- macro_rules! to_string_str_wrap_in_ref {
2948
- { x $( $x: ident) * } => {
2949
- & to_string_str_wrap_in_ref! { $( $x) * }
2950
- } ;
2951
- { } => { str } ;
2952
- }
2953
- #[ cfg( not( no_global_oom_handling) ) ]
2954
- macro_rules! to_string_expr_wrap_in_deref {
2955
- { $self: expr ; x $( $x: ident) * } => {
2956
- * ( to_string_expr_wrap_in_deref! { $self ; $( $x) * } )
2957
- } ;
2958
- { $self: expr ; } => { $self } ;
2959
- }
2960
2942
#[ cfg( not( no_global_oom_handling) ) ]
2961
2943
macro_rules! to_string_str {
2962
- { $( $( $x : ident ) * ) ,+ } => {
2944
+ { $( $type : ty , ) * } => {
2963
2945
$(
2964
- impl SpecToString for to_string_str_wrap_in_ref! ( $ ( $x ) * ) {
2946
+ impl SpecToString for $type {
2965
2947
#[ inline]
2966
2948
fn spec_to_string( & self ) -> String {
2967
- String :: from( to_string_expr_wrap_in_deref!( self ; $( $x) * ) )
2949
+ let s: & str = self ;
2950
+ String :: from( s)
2968
2951
}
2969
2952
}
2970
- ) +
2953
+ ) *
2971
2954
} ;
2972
2955
}
2973
2956
2974
2957
#[ cfg( not( no_global_oom_handling) ) ]
2975
2958
to_string_str ! {
2976
- x x x x x x x x x x x x,
2977
- x x x x x x x x x x x,
2978
- x x x x x x x x x x,
2979
- x x x x x x x x x,
2980
- x x x x x x x x,
2981
- x x x x x x x,
2982
- x x x x x x,
2983
- x x x x x,
2984
- x x x x,
2985
- x x x,
2986
- x x,
2987
- x,
2988
- }
2989
-
2990
- #[ cfg( not( no_global_oom_handling) ) ]
2991
- impl SpecToString for Cow < ' _ , str > {
2992
- #[ inline]
2993
- fn spec_to_string ( & self ) -> String {
2994
- self [ ..] . to_owned ( )
2995
- }
2996
- }
2997
-
2998
- #[ cfg( not( no_global_oom_handling) ) ]
2999
- impl SpecToString for String {
3000
- #[ inline]
3001
- fn spec_to_string ( & self ) -> String {
3002
- self . to_owned ( )
3003
- }
2959
+ Cow <' _, str >,
2960
+ String ,
2961
+ // Generic/generated code can sometimes have multiple, nested references
2962
+ // for strings, including `&&&str`s that would never be written
2963
+ // by hand.
2964
+ &&&&&&&&&&&&str ,
2965
+ &&&&&&&&&&& str ,
2966
+ &&&&&&&&&&str ,
2967
+ &&&&&&&&& str ,
2968
+ &&&&&&&&str ,
2969
+ &&&&&&& str ,
2970
+ &&&&&&str ,
2971
+ &&&&& str ,
2972
+ &&&&str ,
2973
+ &&& str ,
2974
+ &&str ,
2975
+ & str ,
2976
+ str ,
3004
2977
}
3005
2978
3006
2979
#[ cfg( not( no_global_oom_handling) ) ]
0 commit comments