@@ -2682,6 +2682,10 @@ pub trait ToString<const COOP_PREFERRED: bool = {DEFAULT_COOP_PREFERRED!()}>
2682
2682
where
2683
2683
[ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
2684
2684
{
2685
+ /// NOT for public use. Do not override. This exists to woraround (current) limitations of const generic defaults.
2686
+ #[ unstable( feature = "global_co_alloc" , issue = "none" ) ]
2687
+ type RESULT = String < COOP_PREFERRED > ;
2688
+
2685
2689
/// Converts the given value to a `String`.
2686
2690
///
2687
2691
/// # Examples
@@ -2696,7 +2700,7 @@ where
2696
2700
/// ```
2697
2701
#[ rustc_conversion_suggestion]
2698
2702
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2699
- fn to_string ( & self ) -> String < COOP_PREFERRED > ;
2703
+ fn to_string ( & self ) -> Self :: RESULT ;
2700
2704
}
2701
2705
2702
2706
/// # Panics
@@ -2728,18 +2732,24 @@ where
2728
2732
2729
2733
#[ cfg( not( no_global_oom_handling) ) ]
2730
2734
#[ stable( feature = "char_to_string_specialization" , since = "1.46.0" ) ]
2731
- impl ToString for char {
2735
+ impl < const COOP_PREFERRED : bool > ToString < COOP_PREFERRED > for char
2736
+ where
2737
+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
2738
+ {
2732
2739
#[ inline]
2733
- fn to_string ( & self ) -> String {
2740
+ fn to_string ( & self ) -> String < COOP_PREFERRED > {
2734
2741
String :: from ( self . encode_utf8 ( & mut [ 0 ; 4 ] ) )
2735
2742
}
2736
2743
}
2737
2744
2738
2745
#[ cfg( not( no_global_oom_handling) ) ]
2739
2746
#[ stable( feature = "bool_to_string_specialization" , since = "CURRENT_RUSTC_VERSION" ) ]
2740
- impl ToString for bool {
2747
+ impl < const COOP_PREFERRED : bool > ToString < COOP_PREFERRED > for bool
2748
+ where
2749
+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
2750
+ {
2741
2751
#[ inline]
2742
- fn to_string ( & self ) -> String {
2752
+ fn to_string ( & self ) -> String < COOP_PREFERRED > {
2743
2753
String :: from ( if * self { "true" } else { "false" } )
2744
2754
}
2745
2755
}
@@ -3291,7 +3301,7 @@ where
3291
3301
/// assert_eq!("a", &s[..]);
3292
3302
/// ```
3293
3303
#[ inline]
3294
- fn from ( c : char ) -> Self {
3304
+ fn from ( c : char ) -> String < COOP_PREFERRED > {
3295
3305
c. to_string ( )
3296
3306
}
3297
3307
}
0 commit comments