pub fn new(array: LPSAFEARRAY) -> Result<Self, SafeSliceError> {
        let mut data: *mut T = ptr::null_mut();
        let res = unsafe {
            SafeArrayAccessData(array, &mut data as *mut _ as *mut _)
        };
        match res {
            E_INVALIDARG => return Err(SafeSliceError::InvalidSafeArray),
            E_UNEXPECTED => return Err(SafeSliceError::LockFailed),
            S_OK => {},
            _ => panic!("undocumented HRESULT from SafeArrayAccessData!"),
        };

        let dims = unsafe { (*array).cDims as usize };
        let elt_size = unsafe { (*array).cbElements as usize };

        if dims != 1 {
              unsafe { SafeArrayUnaccessData(array); }
              return Err(SafeSliceError::InvalidDimensions(dims));
        }

        if elt_size != mem::size_of::<T>() {
              unsafe { SafeArrayUnaccessData(array); }
              return Err(SafeSliceError::InvalidElementSize(elt_size));
        }

        Ok(SafeSlice {
            wrapped: array,
            data: data,
        })
    }
/* SAFETY: ensure that array is a pointer to a valid SAFEARRAY object
     *   (and, ideally, that it contains values of type T - we check the element
     *   size but have no way to check the element type)
     */
ensure that array is a pointer to a valid SAFEARRAY object
(and, ideally, that it contains values of type T - we check the element
size but have no way to check the element type)
ensure that array is a pointer to a valid SAFEARRAY object ( and ideally that it contains values of type T - we check the element size but have no way to check the element type )
pub fn new(array: LPSAFEARRAY) -> Result<Self, SafeSliceError> {
        let mut data: *mut T = ptr::null_mut();
        let res = unsafe {
            SafeArrayAccessData(array, &mut data as *mut _ as *mut _)
        };
        match res {
            E_INVALIDARG => return Err(SafeSliceError::InvalidSafeArray),
            E_UNEXPECTED => return Err(SafeSliceError::LockFailed),
            S_OK => {},
            _ => panic!("undocumented HRESULT from SafeArrayAccessData!"),
        };
        let dims = unsafe { (*array).cDims as usize };
        let elt_size = unsafe { (*array).cbElements as usize };
        if dims != 1 {
              unsafe { SafeArrayUnaccessData(array); }
              return Err(SafeSliceError::InvalidDimensions(dims));
        }
        if elt_size != mem::size_of::<T>() {
              unsafe { SafeArrayUnaccessData(array); }
              return Err(SafeSliceError::InvalidElementSize(elt_size));
        }
        Ok(SafeSlice {
            wrapped: array,
            data: data,
        })
    }
pub fn new ( array : LPSAFEARRAY ) -> Result < Self , SafeSliceError > { let mut data : * mut T = ptr :: null_mut ( ) ; let res = unsafe { SafeArrayAccessData ( array , & mut data as * mut _ as * mut _ ) } ; match res { E_INVALIDARG => return Err ( SafeSliceError :: InvalidSafeArray ) , E_UNEXPECTED => return Err ( SafeSliceError :: LockFailed ) , S_OK => { } , _ => panic ! ( " " ) , } ; let dims = unsafe { ( * array ) . cDims as usize } ; let elt_size = unsafe { ( * array ) . cbElements as usize } ; if dims != 1 { unsafe { SafeArrayUnaccessData ( array ) ; } return Err ( SafeSliceError :: InvalidDimensions ( dims ) ) ; } if elt_size != mem :: size_of :: < T > ( ) { unsafe { SafeArrayUnaccessData ( array ) ; } return Err ( SafeSliceError :: InvalidElementSize ( elt_size ) ) ; } Ok ( SafeSlice { wrapped : array , data : data , } ) }
SAFETY: ensure that array is a pointer to a valid SAFEARRAY object
   (and, ideally, that it contains values of type T - we check the element
   size but have no way to check the element type)
SAFETY : ensure that array is a pointer to a valid SAFEARRAY object ( and ideally that it contains values of type T - we check the element size but have no way to check the element type )
array
LPSAFEARRAY