summaryrefslogtreecommitdiff
path: root/vendor/windows-core/src/param_value.rs
blob: 4500e261e8365c0c2d6697bf7738e74b16f90aa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use super::*;
use core::mem::transmute_copy;

#[doc(hidden)]
pub enum ParamValue<T: Type<T>> {
    Owned(T),
    Borrowed(T::Abi),
}

impl<T: Type<T>> ParamValue<T> {
    // TODO: replace with `borrow` in windows-bindgen
    pub fn abi(&self) -> T::Abi {
        unsafe {
            match self {
                Self::Owned(item) => transmute_copy(item),
                Self::Borrowed(borrowed) => transmute_copy(borrowed),
            }
        }
    }

    pub fn borrow(&self) -> Ref<'_, T> {
        unsafe { transmute_copy(&self.abi()) }
    }
}