File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use core::ops::{Add, AddAssign};
1111#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1212pub use core:: borrow:: { Borrow , BorrowMut } ;
1313
14- use crate :: fmt;
14+ use crate :: { fmt, DEFAULT_COOP_PREFERRED , alloc :: Global } ;
1515#[ cfg( not( no_global_oom_handling) ) ]
1616use crate :: string:: String ;
1717
3535/// from any borrow of a given type.
3636#[ cfg_attr( not( test) , rustc_diagnostic_item = "ToOwned" ) ]
3737#[ stable( feature = "rust1" , since = "1.0.0" ) ]
38- pub trait ToOwned {
38+ #[ allow( unused_braces) ]
39+ pub trait ToOwned <const COOP_PREFERRED : bool = { DEFAULT_COOP_PREFERRED ! ( ) } >
40+ where
41+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
42+ {
3943 /// The resulting type after obtaining ownership.
4044 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
4145 type Owned : Borrow < Self > ;
Original file line number Diff line number Diff line change @@ -208,14 +208,17 @@ impl BorrowMut<str> for String {
208208
209209#[ cfg( not( no_global_oom_handling) ) ]
210210#[ stable( feature = "rust1" , since = "1.0.0" ) ]
211- impl ToOwned for str {
212- type Owned = String ;
211+ impl < const COOP_PREFERRED : bool > ToOwned < COOP_PREFERRED > for str
212+ where
213+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
214+ {
215+ type Owned = String < COOP_PREFERRED > ;
213216 #[ inline]
214- fn to_owned ( & self ) -> String {
217+ fn to_owned ( & self ) -> String < COOP_PREFERRED > {
215218 unsafe { String :: from_utf8_unchecked ( self . as_bytes ( ) . to_owned ( ) ) }
216219 }
217220
218- fn clone_into ( & self , target : & mut String ) {
221+ fn clone_into ( & self , target : & mut String < COOP_PREFERRED > ) {
219222 let mut b = mem:: take ( target) . into_bytes ( ) ;
220223 self . as_bytes ( ) . clone_into ( & mut b) ;
221224 * target = unsafe { String :: from_utf8_unchecked ( b) }
You can’t perform that action at this time.
0 commit comments