variant_rs/com_types/
bool.rs1#![allow(unused_imports)]
4use windows::Win32::Foundation::{BOOL, VARIANT_BOOL};
5
6use enumn::N;
7
8#[derive(N, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
10#[repr(i16)]
11pub enum ComBool {
12 False = 0i16,
13 True = !0i16,
14}
15
16impl From<&mut i16> for &'static mut ComBool {
17 fn from(value: &mut i16) -> &'static mut ComBool {
18 unsafe { &mut *(value as *mut i16 as *mut ComBool) }
19 }
20}
21
22impl From<&mut VARIANT_BOOL> for &'static mut ComBool {
23 fn from(value: &mut VARIANT_BOOL) -> &'static mut ComBool {
24 unsafe { &mut *(value as *const VARIANT_BOOL as *mut ComBool) }
25 }
26}
27
28impl From<ComBool> for bool {
29 fn from(value: ComBool) -> bool {
30 value != ComBool::False
31 }
32}
33
34impl From<bool> for ComBool {
35 fn from(value: bool) -> ComBool {
36 if value {
37 ComBool::True
38 } else {
39 ComBool::False
40 }
41 }
42}