use super::*; use core::mem::{take, transmute_copy, zeroed}; /// Provides automatic parameter conversion in cases where the Windows API expects implicit conversion support. /// /// This is a mutable version of [Param] meant to support out parameters. /// There is no need to implement this trait. Blanket implementations are provided for all applicable Windows types. pub trait OutParam::TypeKind>: Sized where T: Type, { #[doc(hidden)] unsafe fn borrow_mut(&self) -> OutRef<'_, T>; } impl OutParam for &mut T where T: TypeKind + Clone + Default, { unsafe fn borrow_mut(&self) -> OutRef<'_, T> { let this: &mut T = transmute_copy(self); take(this); transmute_copy(self) } } impl OutParam for &mut T where T: TypeKind + Clone + Default, { unsafe fn borrow_mut(&self) -> OutRef<'_, T> { transmute_copy(self) } } impl OutParam for &mut Option where T: TypeKind + Clone, { unsafe fn borrow_mut(&self) -> OutRef<'_, T> { let this: &mut Option = transmute_copy(self); take(this); transmute_copy(self) } } impl OutParam for Option<&mut T> where T: Type, { unsafe fn borrow_mut(&self) -> OutRef<'_, T> { match self { Some(this) => transmute_copy(this), None => zeroed(), } } }