File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -361,9 +361,7 @@ impl DerefMut for WString {
361361impl < ' a > From < & ' a WStr > for WString {
362362 #[ inline]
363363 fn from ( s : & ' a WStr ) -> Self {
364- let mut buf = Self :: new ( ) ;
365- buf. push_str ( s) ;
366- buf
364+ s. to_owned ( )
367365 }
368366}
369367
Original file line number Diff line number Diff line change 1+ use alloc:: borrow:: ToOwned ;
12use core:: ops:: Range ;
23use core:: ptr:: { slice_from_raw_parts, slice_from_raw_parts_mut} ;
34
4- use super :: Units ;
5+ use super :: { Units , WString } ;
56
67#[ cfg( not( any( target_pointer_width = "32" , target_pointer_width = "64" ) ) ) ]
78compile_error ! ( "WStr only supports 32-bits and 64-bits targets" ) ;
@@ -46,6 +47,16 @@ pub struct WStr {
4647 _repr : [ ( ) ] ,
4748}
4849
50+ impl ToOwned for WStr {
51+ type Owned = WString ;
52+
53+ fn to_owned ( & self ) -> Self :: Owned {
54+ let mut buf = WString :: new ( ) ;
55+ buf. push_str ( self ) ;
56+ buf
57+ }
58+ }
59+
4960/// Convenience method to turn a `&T` into a `*mut T`.
5061#[ inline]
5162pub fn ptr_mut < T : ?Sized > ( t : & T ) -> * mut T {
You can’t perform that action at this time.
0 commit comments