pub unsafe fn from_ptr<'a>(ptr: *const u16) -> &'a BStr
    {
        // The BStr invariant 1 states the ptr must be valid BSTR pointer,
        // which is u32-aligned.
        #![allow(clippy::cast_ptr_alignment)]
        let (len, final_ptr) = match ptr as usize {
            0 => (0, 1 as *const u8),
            _ => (*(ptr.offset(-2) as *const u32), ptr as *const u8),
        };

        let slice = std::slice::from_raw_parts(final_ptr, len as usize);
        Self::from_slice_unchecked(slice)
    }
/// Unsafely creates a `BStr` from a BSTR pointer.
///
/// This function will cast the pointer into a `BStr`. The provied pointer
/// **must** be a valid BSTR pointer and must be valid while the BStr is
/// alive. The BStr must also not be moved.
///
/// # Safety
///
/// The parameter must be a valid BSTR pointer. This includes both the
/// memory layout and allocation using BSTR-compatible allocation
/// functions.
///
/// In addition to this the pointer must be kept alive while the returned
/// reference is in use.
Unsafely creates a `BStr` from a BSTR pointer.
This function will cast the pointer into a `BStr`. The provied pointer
must** be a valid BSTR pointer and must be valid while the BStr is
alive. The BStr must also not be moved.
Unsafely creates a ` BStr ` from a BSTR pointer . This function will cast the pointer into a ` BStr ` . The provied pointer must ** be a valid BSTR pointer and must be valid while the BStr is alive . The BStr must also not be moved .
pub unsafe fn from_ptr<'a>(ptr: *const u16) -> &'a BStr
    {
        // The BStr invariant 1 states the ptr must be valid BSTR pointer,
        // which is u32-aligned.
        #![allow(clippy::cast_ptr_alignment)]
        let (len, final_ptr) = match ptr as usize {
            0 => (0, 1 as *const u8),
            _ => (*(ptr.offset(-2) as *const u32), ptr as *const u8),
        };
        let slice = std::slice::from_raw_parts(final_ptr, len as usize);
        Self::from_slice_unchecked(slice)
    }
pub unsafe fn from_ptr < ' a > ( ptr : * const u16 ) -> & ' a BStr { // The BStr invariant 1 states the ptr must be valid BSTR pointer, // which is u32-aligned. # ! [ allow ( clippy cast_ptr_alignment ) ] let ( len , final_ptr ) = match ptr as usize { 0 => ( 0 , 1 as * const u8 ) , _ => ( * ( ptr . offset ( - 2 ) as * const u32 ) , ptr as * const u8 ) , } ; let slice = std :: slice :: from_raw_parts ( final_ptr , len as usize ) ; Self :: from_slice_unchecked ( slice ) }
Unsafely creates a `BStr` from a BSTR pointer.
Unsafely creates a ` BStr ` from a BSTR pointer .
ptr
*const u16
ptr
*const u16
safety
The parameter must be a valid BSTR pointer. This includes both the
memory layout and allocation using BSTR-compatible allocation
functions.

In addition to this the pointer must be kept alive while the returned
reference is in use.
The parameter must be a valid BSTR pointer . This includes both the memory layout and allocation using BSTR - compatible allocation functions . In addition to this the pointer must be kept alive while the returned reference is in use .