55// All files in the project carrying such notice may not be copied, modified, or distributed
66// except according to those terms.
77
8- #![ allow( unused) ]
9-
108use crate :: windows:: {
119 winapi:: { IUnknown , Interface } ,
1210 windows_sys:: {
@@ -16,10 +14,9 @@ use crate::windows::{
1614} ;
1715use std:: {
1816 convert:: TryInto ,
19- ffi:: { OsStr , OsString } ,
20- mem:: ManuallyDrop ,
17+ ffi:: OsString ,
2118 ops:: Deref ,
22- os:: windows:: ffi:: { OsStrExt , OsStringExt } ,
19+ os:: windows:: ffi:: OsStringExt ,
2320 ptr:: { null, null_mut} ,
2421 slice:: from_raw_parts,
2522} ;
4845 assert ! ( !ptr. is_null( ) ) ;
4946 ComPtr ( ptr)
5047 }
51- /// Casts up the inheritance chain
52- pub fn up < U > ( self ) -> ComPtr < U >
53- where
54- T : Deref < Target = U > ,
55- U : Interface ,
56- {
57- ComPtr ( self . into_raw ( ) as * mut U )
58- }
59- /// Extracts the raw pointer.
60- /// You are now responsible for releasing it yourself.
61- pub fn into_raw ( self ) -> * mut T {
62- ManuallyDrop :: new ( self ) . 0
63- }
6448 /// For internal use only.
6549 fn as_unknown ( & self ) -> & IUnknown {
6650 unsafe { & * ( self . 0 as * mut IUnknown ) }
@@ -124,34 +108,3 @@ impl Drop for BStr {
124108 unsafe { SysFreeString ( self . 0 ) } ;
125109 }
126110}
127-
128- pub trait ToWide {
129- fn to_wide ( & self ) -> Vec < u16 > ;
130- fn to_wide_null ( & self ) -> Vec < u16 > ;
131- }
132- impl < T > ToWide for T
133- where
134- T : AsRef < OsStr > ,
135- {
136- fn to_wide ( & self ) -> Vec < u16 > {
137- self . as_ref ( ) . encode_wide ( ) . collect ( )
138- }
139- fn to_wide_null ( & self ) -> Vec < u16 > {
140- self . as_ref ( ) . encode_wide ( ) . chain ( Some ( 0 ) ) . collect ( )
141- }
142- }
143- pub trait FromWide
144- where
145- Self : Sized ,
146- {
147- fn from_wide ( wide : & [ u16 ] ) -> Self ;
148- fn from_wide_null ( wide : & [ u16 ] ) -> Self {
149- let len = wide. iter ( ) . take_while ( |& & c| c != 0 ) . count ( ) ;
150- Self :: from_wide ( & wide[ ..len] )
151- }
152- }
153- impl FromWide for OsString {
154- fn from_wide ( wide : & [ u16 ] ) -> OsString {
155- OsStringExt :: from_wide ( wide)
156- }
157- }
0 commit comments