]> git.proxmox.com Git - rustc.git/blob - vendor/windows-bindgen/src/extensions/mod/Win32/Foundation/BOOLEAN.rs
New upstream version 1.71.1+dfsg1
[rustc.git] / vendor / windows-bindgen / src / extensions / mod / Win32 / Foundation / BOOLEAN.rs
1 impl BOOLEAN {
2 #[inline]
3 pub fn as_bool(self) -> bool {
4 self.0 != 0
5 }
6 #[inline]
7 pub fn ok(self) -> ::windows::core::Result<()> {
8 if self.as_bool() {
9 Ok(())
10 } else {
11 Err(::windows::core::Error::from_win32())
12 }
13 }
14 #[inline]
15 #[track_caller]
16 pub fn unwrap(self) {
17 self.ok().unwrap();
18 }
19 #[inline]
20 #[track_caller]
21 pub fn expect(self, msg: &str) {
22 self.ok().expect(msg);
23 }
24 }
25 impl ::core::convert::From<BOOLEAN> for bool {
26 fn from(value: BOOLEAN) -> Self {
27 value.as_bool()
28 }
29 }
30 impl ::core::convert::From<&BOOLEAN> for bool {
31 fn from(value: &BOOLEAN) -> Self {
32 value.as_bool()
33 }
34 }
35 impl ::core::convert::From<bool> for BOOLEAN {
36 fn from(value: bool) -> Self {
37 if value {
38 Self(1)
39 } else {
40 Self(0)
41 }
42 }
43 }
44 impl ::core::convert::From<&bool> for BOOLEAN {
45 fn from(value: &bool) -> Self {
46 (*value).into()
47 }
48 }
49 impl ::core::cmp::PartialEq<bool> for BOOLEAN {
50 fn eq(&self, other: &bool) -> bool {
51 self.as_bool() == *other
52 }
53 }
54 impl ::core::cmp::PartialEq<BOOLEAN> for bool {
55 fn eq(&self, other: &BOOLEAN) -> bool {
56 *self == other.as_bool()
57 }
58 }
59 impl ::core::ops::Not for BOOLEAN {
60 type Output = Self;
61 fn not(self) -> Self::Output {
62 if self.as_bool() {
63 Self(0)
64 } else {
65 Self(1)
66 }
67 }
68 }