pub fn string_to_bstr( s : &str ) -> BStr {

        // Avoid unnecessary allocations when the string is empty.
        // Null and empty BSTRs should be treated as equal.
        // See https://blogs.msdn.microsoft.com/ericlippert/2003/09/12/erics-complete-guide-to-bstr-semantics/
        let len = s.len() as u32;
        if len == 0 { return BStr( std::ptr::null_mut() ); }

        unsafe {

            let bstr = SysAllocStringLen(
                s.encode_utf16().collect::<Vec<_>>().as_ptr(),
                len );
            if bstr.is_null() { panic!( "Allocating BStr failed." ); }
            bstr
        }
    }
/// Converts a Rust string into a `BStr`.
Converts a Rust string into a `BStr`.
Converts a Rust string into a ` BStr ` .
pub fn string_to_bstr( s : &str ) -> BStr {
        // Avoid unnecessary allocations when the string is empty.
        // Null and empty BSTRs should be treated as equal.
        // See https://blogs.msdn.microsoft.com/ericlippert/2003/09/12/erics-complete-guide-to-bstr-semantics/
        let len = s.len() as u32;
        if len == 0 { return BStr( std::ptr::null_mut() ); }
        unsafe {
            let bstr = SysAllocStringLen(
                s.encode_utf16().collect::<Vec<_>>().as_ptr(),
                len );
            if bstr.is_null() { panic!( "Allocating BStr failed." ); }
            bstr
        }
    }
pub fn string_to_bstr ( s : & str ) -> BStr { // Avoid unnecessary allocations when the string is empty. // Null and empty BSTRs should be treated as equal. // See https://blogs.msdn.microsoft.com/ericlippert/2003/09/12/erics-complete-guide-to-bstr-semantics/ let len = s . len ( ) as u32 ; if len == 0 { return BStr ( std :: ptr :: null_mut ( ) ) ; } unsafe { let bstr = SysAllocStringLen ( s . encode_utf16 ( ) . collect :: < Vec < _ > > ( ) . as_ptr ( ) , len ) ; if bstr . is_null ( ) { panic ! ( " " ) ; } bstr } }
Converts a Rust string into a `BStr`.
Converts a Rust string into a ` BStr ` .
s
&str