| 1 | use super::*; |
| 2 | use core::mem::transmute_copy; |
| 3 | |
| 4 | #[doc (hidden)] |
| 5 | pub enum ParamValue<T: Type<T>> { |
| 6 | Owned(T), |
| 7 | Borrowed(T::Abi), |
| 8 | } |
| 9 | |
| 10 | impl<T: Type<T>> ParamValue<T> { |
| 11 | // TODO: replace with `borrow` in windows-bindgen |
| 12 | pub fn abi(&self) -> T::Abi { |
| 13 | unsafe { |
| 14 | match self { |
| 15 | Self::Owned(item: &T) => transmute_copy(src:item), |
| 16 | Self::Borrowed(borrowed: &::TypeKind>>::Abi) => transmute_copy(src:borrowed), |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | pub fn borrow(&self) -> Ref<'_, T> { |
| 22 | unsafe { transmute_copy(&self.abi()) } |
| 23 | } |
| 24 | } |
| 25 | |