Coverage Report

Created: 2025-08-29 06:27

/rust/registry/src/index.crates.io-6f17d22bba15001f/bitflags-2.9.3/src/public.rs
Line
Count
Source (jump to first uncovered line)
1
//! Generate the user-facing flags type.
2
//!
3
//! The code here belongs to the end-user, so new trait implementations and methods can't be
4
//! added without potentially breaking users.
5
6
/// Declare the user-facing bitflags struct.
7
///
8
/// This type is guaranteed to be a newtype with a `bitflags`-facing type as its single field.
9
#[macro_export]
10
#[doc(hidden)]
11
macro_rules! __declare_public_bitflags {
12
    (
13
        $(#[$outer:meta])*
14
        $vis:vis struct $PublicBitFlags:ident
15
    ) => {
16
        $(#[$outer])*
17
        $vis struct $PublicBitFlags(<$PublicBitFlags as $crate::__private::PublicFlags>::Internal);
18
    };
19
}
20
21
/// Implement functions on the public (user-facing) bitflags type.
22
///
23
/// We need to be careful about adding new methods and trait implementations here because they
24
/// could conflict with items added by the end-user.
25
#[macro_export]
26
#[doc(hidden)]
27
macro_rules! __impl_public_bitflags_forward {
28
    (
29
        $(#[$outer:meta])*
30
        $PublicBitFlags:ident: $T:ty, $InternalBitFlags:ident
31
    ) => {
32
        $crate::__impl_bitflags! {
33
            params: self, bits, name, other, value;
34
            $(#[$outer])*
35
            $PublicBitFlags: $T {
36
5.59M
                fn empty() {
37
5.59M
                    Self($InternalBitFlags::empty())
<ron::extensions::Extensions>::empty
Line
Count
Source
36
1.98k
                fn empty() {
37
1.98k
                    Self($InternalBitFlags::empty())
<ron::extensions::Extensions>::empty
Line
Count
Source
36
4.20M
                fn empty() {
37
4.20M
                    Self($InternalBitFlags::empty())
<ron::extensions::Extensions>::empty
Line
Count
Source
36
1.38M
                fn empty() {
37
1.38M
                    Self($InternalBitFlags::empty())
38
                }
39
40
29.2k
                fn all() {
41
29.2k
                    Self($InternalBitFlags::all())
42
                }
43
44
1.23M
                fn bits(&self) {
45
1.23M
                    self.0.bits()
Unexecuted instantiation: <ron::extensions::Extensions>::bits
<ron::extensions::Extensions>::bits
Line
Count
Source
44
1.05M
                fn bits(&self) {
45
1.05M
                    self.0.bits()
<ron::extensions::Extensions>::bits
Line
Count
Source
44
179k
                fn bits(&self) {
45
179k
                    self.0.bits()
46
                }
47
48
19.1k
                fn from_bits(bits) {
49
19.1k
                    match $InternalBitFlags::from_bits(bits) {
50
19.1k
                        $crate::__private::core::option::Option::Some(bits) => $crate::__private::core::option::Option::Some(Self(bits)),
51
3
                        $crate::__private::core::option::Option::None => $crate::__private::core::option::Option::None,
Unexecuted instantiation: <ron::extensions::Extensions>::from_bits
<ron::extensions::Extensions>::from_bits
Line
Count
Source
48
19.1k
                fn from_bits(bits) {
49
19.1k
                    match $InternalBitFlags::from_bits(bits) {
50
19.1k
                        $crate::__private::core::option::Option::Some(bits) => $crate::__private::core::option::Option::Some(Self(bits)),
51
3
                        $crate::__private::core::option::Option::None => $crate::__private::core::option::Option::None,
52
                    }
53
                }
54
55
0
                fn from_bits_truncate(bits) {
56
0
                    Self($InternalBitFlags::from_bits_truncate(bits))
57
                }
58
59
585k
                fn from_bits_retain(bits) {
60
585k
                    Self($InternalBitFlags::from_bits_retain(bits))
Unexecuted instantiation: <ron::extensions::Extensions>::from_bits_retain
<ron::extensions::Extensions>::from_bits_retain
Line
Count
Source
59
551k
                fn from_bits_retain(bits) {
60
551k
                    Self($InternalBitFlags::from_bits_retain(bits))
<ron::extensions::Extensions>::from_bits_retain
Line
Count
Source
59
34.3k
                fn from_bits_retain(bits) {
60
34.3k
                    Self($InternalBitFlags::from_bits_retain(bits))
61
                }
62
63
0
                fn from_name(name) {
64
0
                    match $InternalBitFlags::from_name(name) {
65
0
                        $crate::__private::core::option::Option::Some(bits) => $crate::__private::core::option::Option::Some(Self(bits)),
66
0
                        $crate::__private::core::option::Option::None => $crate::__private::core::option::Option::None,
67
                    }
68
                }
69
70
332k
                fn is_empty(&self) {
71
332k
                    self.0.is_empty()
72
                }
73
74
0
                fn is_all(&self) {
75
0
                    self.0.is_all()
76
                }
77
78
0
                fn intersects(&self, other) {
79
0
                    self.0.intersects(other.0)
80
                }
81
82
4.28M
                fn contains(&self, other) {
83
4.28M
                    self.0.contains(other.0)
<ron::extensions::Extensions>::contains
Line
Count
Source
82
1.98k
                fn contains(&self, other) {
83
1.98k
                    self.0.contains(other.0)
<ron::extensions::Extensions>::contains
Line
Count
Source
82
66.3k
                fn contains(&self, other) {
83
66.3k
                    self.0.contains(other.0)
<ron::extensions::Extensions>::contains
Line
Count
Source
82
4.21M
                fn contains(&self, other) {
83
4.21M
                    self.0.contains(other.0)
84
                }
85
86
295k
                fn insert(&mut self, other) {
87
295k
                    self.0.insert(other.0)
88
                }
89
90
0
                fn remove(&mut self, other) {
91
0
                    self.0.remove(other.0)
92
                }
93
94
0
                fn toggle(&mut self, other) {
95
0
                    self.0.toggle(other.0)
96
                }
97
98
0
                fn set(&mut self, other, value) {
99
0
                    self.0.set(other.0, value)
100
                }
101
102
17.1k
                fn intersection(self, other) {
103
17.1k
                    Self(self.0.intersection(other.0))
Unexecuted instantiation: <ron::extensions::Extensions>::intersection
Unexecuted instantiation: <ron::extensions::Extensions>::intersection
<ron::extensions::Extensions>::intersection
Line
Count
Source
102
17.1k
                fn intersection(self, other) {
103
17.1k
                    Self(self.0.intersection(other.0))
104
                }
105
106
1.38M
                fn union(self, other) {
107
1.38M
                    Self(self.0.union(other.0))
<ron::extensions::Extensions>::union
Line
Count
Source
106
1.98k
                fn union(self, other) {
107
1.98k
                    Self(self.0.union(other.0))
Unexecuted instantiation: <ron::extensions::Extensions>::union
<ron::extensions::Extensions>::union
Line
Count
Source
106
1.38M
                fn union(self, other) {
107
1.38M
                    Self(self.0.union(other.0))
108
                }
109
110
0
                fn difference(self, other) {
111
0
                    Self(self.0.difference(other.0))
112
                }
113
114
0
                fn symmetric_difference(self, other) {
115
0
                    Self(self.0.symmetric_difference(other.0))
116
                }
117
118
17.1k
                fn complement(self) {
119
17.1k
                    Self(self.0.complement())
Unexecuted instantiation: <ron::extensions::Extensions>::complement
Unexecuted instantiation: <ron::extensions::Extensions>::complement
<ron::extensions::Extensions>::complement
Line
Count
Source
118
17.1k
                fn complement(self) {
119
17.1k
                    Self(self.0.complement())
120
                }
121
            }
122
        }
123
    };
124
}
125
126
/// Implement functions on the public (user-facing) bitflags type.
127
///
128
/// We need to be careful about adding new methods and trait implementations here because they
129
/// could conflict with items added by the end-user.
130
#[macro_export]
131
#[doc(hidden)]
132
macro_rules! __impl_public_bitflags {
133
    (
134
        $(#[$outer:meta])*
135
        $BitFlags:ident: $T:ty, $PublicBitFlags:ident {
136
            $(
137
                $(#[$inner:ident $($args:tt)*])*
138
                const $Flag:tt = $value:expr;
139
            )*
140
        }
141
    ) => {
142
        $crate::__impl_bitflags! {
143
            params: self, bits, name, other, value;
144
            $(#[$outer])*
145
            $BitFlags: $T {
146
5.59M
                fn empty() {
147
5.59M
                    Self(<$T as $crate::Bits>::EMPTY)
<ron::extensions::_::InternalBitFlags>::empty
Line
Count
Source
146
1.98k
                fn empty() {
147
1.98k
                    Self(<$T as $crate::Bits>::EMPTY)
<ron::extensions::_::InternalBitFlags>::empty
Line
Count
Source
146
4.20M
                fn empty() {
147
4.20M
                    Self(<$T as $crate::Bits>::EMPTY)
<ron::extensions::_::InternalBitFlags>::empty
Line
Count
Source
146
1.38M
                fn empty() {
147
1.38M
                    Self(<$T as $crate::Bits>::EMPTY)
148
                }
149
150
65.5k
                fn all() {
151
65.5k
                    let mut truncated = <$T as $crate::Bits>::EMPTY;
152
65.5k
                    let mut i = 0;
153
65.5k
154
65.5k
                    $(
155
65.5k
                        $crate::__bitflags_expr_safe_attrs!(
156
65.5k
                            $(#[$inner $($args)*])*
157
65.5k
                            {{
158
65.5k
                                let flag = <$PublicBitFlags as $crate::Flags>::FLAGS[i].value().bits();
159
65.5k
160
65.5k
                                truncated = truncated | flag;
161
65.5k
                                i += 1;
162
65.5k
                            }}
163
65.5k
                        );
164
65.5k
                    )*
165
65.5k
166
65.5k
                    let _ = i;
167
65.5k
                    Self(truncated)
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::all
<ron::extensions::_::InternalBitFlags>::all
Line
Count
Source
150
29.2k
                fn all() {
151
29.2k
                    let mut truncated = <$T as $crate::Bits>::EMPTY;
152
29.2k
                    let mut i = 0;
153
29.2k
154
29.2k
                    $(
155
29.2k
                        $crate::__bitflags_expr_safe_attrs!(
156
29.2k
                            $(#[$inner $($args)*])*
157
29.2k
                            {{
158
29.2k
                                let flag = <$PublicBitFlags as $crate::Flags>::FLAGS[i].value().bits();
159
29.2k
160
29.2k
                                truncated = truncated | flag;
161
29.2k
                                i += 1;
162
29.2k
                            }}
163
29.2k
                        );
164
29.2k
                    )*
165
29.2k
166
29.2k
                    let _ = i;
167
29.2k
                    Self(truncated)
<ron::extensions::_::InternalBitFlags>::all
Line
Count
Source
150
36.2k
                fn all() {
151
36.2k
                    let mut truncated = <$T as $crate::Bits>::EMPTY;
152
36.2k
                    let mut i = 0;
153
36.2k
154
36.2k
                    $(
155
36.2k
                        $crate::__bitflags_expr_safe_attrs!(
156
36.2k
                            $(#[$inner $($args)*])*
157
36.2k
                            {{
158
36.2k
                                let flag = <$PublicBitFlags as $crate::Flags>::FLAGS[i].value().bits();
159
36.2k
160
36.2k
                                truncated = truncated | flag;
161
36.2k
                                i += 1;
162
36.2k
                            }}
163
36.2k
                        );
164
36.2k
                    )*
165
36.2k
166
36.2k
                    let _ = i;
167
36.2k
                    Self(truncated)
168
                }
169
170
1.23M
                fn bits(&self) {
171
1.23M
                    self.0
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::bits
<ron::extensions::_::InternalBitFlags>::bits
Line
Count
Source
170
1.05M
                fn bits(&self) {
171
1.05M
                    self.0
<ron::extensions::_::InternalBitFlags>::bits
Line
Count
Source
170
179k
                fn bits(&self) {
171
179k
                    self.0
172
                }
173
174
19.1k
                fn from_bits(bits) {
175
19.1k
                    let truncated = Self::from_bits_truncate(bits).0;
176
19.1k
177
19.1k
                    if truncated == bits {
178
19.1k
                        $crate::__private::core::option::Option::Some(Self(bits))
179
                    } else {
180
3
                        $crate::__private::core::option::Option::None
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::from_bits
<ron::extensions::_::InternalBitFlags>::from_bits
Line
Count
Source
174
19.1k
                fn from_bits(bits) {
175
19.1k
                    let truncated = Self::from_bits_truncate(bits).0;
176
19.1k
177
19.1k
                    if truncated == bits {
178
19.1k
                        $crate::__private::core::option::Option::Some(Self(bits))
179
                    } else {
180
3
                        $crate::__private::core::option::Option::None
181
                    }
182
                }
183
184
36.2k
                fn from_bits_truncate(bits) {
185
36.2k
                    Self(bits & Self::all().0)
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::from_bits_truncate
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::from_bits_truncate
<ron::extensions::_::InternalBitFlags>::from_bits_truncate
Line
Count
Source
184
36.2k
                fn from_bits_truncate(bits) {
185
36.2k
                    Self(bits & Self::all().0)
186
                }
187
188
585k
                fn from_bits_retain(bits) {
189
585k
                    Self(bits)
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::from_bits_retain
<ron::extensions::_::InternalBitFlags>::from_bits_retain
Line
Count
Source
188
551k
                fn from_bits_retain(bits) {
189
551k
                    Self(bits)
<ron::extensions::_::InternalBitFlags>::from_bits_retain
Line
Count
Source
188
34.3k
                fn from_bits_retain(bits) {
189
34.3k
                    Self(bits)
190
                }
191
192
0
                fn from_name(name) {
193
0
                    $(
194
0
                        $crate::__bitflags_flag!({
195
0
                            name: $Flag,
196
0
                            named: {
197
0
                                $crate::__bitflags_expr_safe_attrs!(
198
0
                                    $(#[$inner $($args)*])*
199
0
                                    {
200
0
                                        if name == $crate::__private::core::stringify!($Flag) {
201
0
                                            return $crate::__private::core::option::Option::Some(Self($PublicBitFlags::$Flag.bits()));
202
0
                                        }
203
0
                                    }
204
0
                                );
205
0
                            },
206
0
                            unnamed: {},
207
0
                        });
208
0
                    )*
209
0
210
0
                    let _ = name;
211
0
                    $crate::__private::core::option::Option::None
212
                }
213
214
332k
                fn is_empty(&self) {
215
332k
                    self.0 == <$T as $crate::Bits>::EMPTY
216
                }
217
218
0
                fn is_all(&self) {
219
0
                    // NOTE: We check against `Self::all` here, not `Self::Bits::ALL`
220
0
                    // because the set of all flags may not use all bits
221
0
                    Self::all().0 | self.0 == self.0
222
                }
223
224
0
                fn intersects(&self, other) {
225
0
                    self.0 & other.0 != <$T as $crate::Bits>::EMPTY
226
                }
227
228
4.28M
                fn contains(&self, other) {
229
4.28M
                    self.0 & other.0 == other.0
<ron::extensions::_::InternalBitFlags>::contains
Line
Count
Source
228
1.98k
                fn contains(&self, other) {
229
1.98k
                    self.0 & other.0 == other.0
<ron::extensions::_::InternalBitFlags>::contains
Line
Count
Source
228
66.3k
                fn contains(&self, other) {
229
66.3k
                    self.0 & other.0 == other.0
<ron::extensions::_::InternalBitFlags>::contains
Line
Count
Source
228
4.21M
                fn contains(&self, other) {
229
4.21M
                    self.0 & other.0 == other.0
230
                }
231
232
295k
                fn insert(&mut self, other) {
233
295k
                    *self = Self(self.0).union(other);
234
                }
235
236
0
                fn remove(&mut self, other) {
237
0
                    *self = Self(self.0).difference(other);
238
                }
239
240
0
                fn toggle(&mut self, other) {
241
0
                    *self = Self(self.0).symmetric_difference(other);
242
                }
243
244
0
                fn set(&mut self, other, value) {
245
0
                    if value {
246
0
                        self.insert(other);
247
0
                    } else {
248
0
                        self.remove(other);
249
0
                    }
250
                }
251
252
17.1k
                fn intersection(self, other) {
253
17.1k
                    Self(self.0 & other.0)
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::intersection
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::intersection
<ron::extensions::_::InternalBitFlags>::intersection
Line
Count
Source
252
17.1k
                fn intersection(self, other) {
253
17.1k
                    Self(self.0 & other.0)
254
                }
255
256
1.67M
                fn union(self, other) {
257
1.67M
                    Self(self.0 | other.0)
<ron::extensions::_::InternalBitFlags>::union
Line
Count
Source
256
1.98k
                fn union(self, other) {
257
1.98k
                    Self(self.0 | other.0)
<ron::extensions::_::InternalBitFlags>::union
Line
Count
Source
256
295k
                fn union(self, other) {
257
295k
                    Self(self.0 | other.0)
<ron::extensions::_::InternalBitFlags>::union
Line
Count
Source
256
1.38M
                fn union(self, other) {
257
1.38M
                    Self(self.0 | other.0)
258
                }
259
260
0
                fn difference(self, other) {
261
0
                    Self(self.0 & !other.0)
262
                }
263
264
0
                fn symmetric_difference(self, other) {
265
0
                    Self(self.0 ^ other.0)
266
                }
267
268
17.1k
                fn complement(self) {
269
17.1k
                    Self::from_bits_truncate(!self.0)
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::complement
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::complement
<ron::extensions::_::InternalBitFlags>::complement
Line
Count
Source
268
17.1k
                fn complement(self) {
269
17.1k
                    Self::from_bits_truncate(!self.0)
270
                }
271
            }
272
        }
273
    };
274
}
275
276
/// Implement iterators on the public (user-facing) bitflags type.
277
#[macro_export]
278
#[doc(hidden)]
279
macro_rules! __impl_public_bitflags_iter {
280
    (
281
        $(#[$outer:meta])*
282
        $BitFlags:ident: $T:ty, $PublicBitFlags:ident
283
    ) => {
284
        $(#[$outer])*
285
        impl $BitFlags {
286
            /// Yield a set of contained flags values.
287
            ///
288
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
289
            /// will be yielded together as a final flags value.
290
            #[inline]
291
0
            pub const fn iter(&self) -> $crate::iter::Iter<$PublicBitFlags> {
292
0
                $crate::iter::Iter::__private_const_new(
293
0
                    <$PublicBitFlags as $crate::Flags>::FLAGS,
294
0
                    $PublicBitFlags::from_bits_retain(self.bits()),
295
0
                    $PublicBitFlags::from_bits_retain(self.bits()),
296
0
                )
297
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::iter
Unexecuted instantiation: <ron::extensions::Extensions>::iter
298
299
            /// Yield a set of contained named flags values.
300
            ///
301
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
302
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
303
            #[inline]
304
46.4k
            pub const fn iter_names(&self) -> $crate::iter::IterNames<$PublicBitFlags> {
305
46.4k
                $crate::iter::IterNames::__private_const_new(
306
46.4k
                    <$PublicBitFlags as $crate::Flags>::FLAGS,
307
46.4k
                    $PublicBitFlags::from_bits_retain(self.bits()),
308
46.4k
                    $PublicBitFlags::from_bits_retain(self.bits()),
309
46.4k
                )
310
46.4k
            }
Unexecuted instantiation: <ron::extensions::Extensions>::iter_names
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags>::iter_names
<ron::extensions::Extensions>::iter_names
Line
Count
Source
304
29.2k
            pub const fn iter_names(&self) -> $crate::iter::IterNames<$PublicBitFlags> {
305
29.2k
                $crate::iter::IterNames::__private_const_new(
306
29.2k
                    <$PublicBitFlags as $crate::Flags>::FLAGS,
307
29.2k
                    $PublicBitFlags::from_bits_retain(self.bits()),
308
29.2k
                    $PublicBitFlags::from_bits_retain(self.bits()),
309
29.2k
                )
310
29.2k
            }
<ron::extensions::Extensions>::iter_names
Line
Count
Source
304
17.1k
            pub const fn iter_names(&self) -> $crate::iter::IterNames<$PublicBitFlags> {
305
17.1k
                $crate::iter::IterNames::__private_const_new(
306
17.1k
                    <$PublicBitFlags as $crate::Flags>::FLAGS,
307
17.1k
                    $PublicBitFlags::from_bits_retain(self.bits()),
308
17.1k
                    $PublicBitFlags::from_bits_retain(self.bits()),
309
17.1k
                )
310
17.1k
            }
311
        }
312
313
        $(#[$outer:meta])*
314
        impl $crate::__private::core::iter::IntoIterator for $BitFlags {
315
            type Item = $PublicBitFlags;
316
            type IntoIter = $crate::iter::Iter<$PublicBitFlags>;
317
318
0
            fn into_iter(self) -> Self::IntoIter {
319
0
                self.iter()
320
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::iter::traits::collect::IntoIterator>::into_iter
Unexecuted instantiation: <ron::extensions::Extensions as core::iter::traits::collect::IntoIterator>::into_iter
321
        }
322
    };
323
}
324
325
/// Implement traits on the public (user-facing) bitflags type.
326
#[macro_export]
327
#[doc(hidden)]
328
macro_rules! __impl_public_bitflags_ops {
329
    (
330
        $(#[$outer:meta])*
331
        $PublicBitFlags:ident
332
    ) => {
333
334
        $(#[$outer])*
335
        impl $crate::__private::core::fmt::Binary for $PublicBitFlags {
336
0
            fn fmt(
337
0
                &self,
338
0
                f: &mut $crate::__private::core::fmt::Formatter,
339
0
            ) -> $crate::__private::core::fmt::Result {
340
0
                let inner = self.0;
341
0
                $crate::__private::core::fmt::Binary::fmt(&inner, f)
342
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::fmt::Binary>::fmt
Unexecuted instantiation: <ron::extensions::Extensions as core::fmt::Binary>::fmt
343
        }
344
345
        $(#[$outer])*
346
        impl $crate::__private::core::fmt::Octal for $PublicBitFlags {
347
0
            fn fmt(
348
0
                &self,
349
0
                f: &mut $crate::__private::core::fmt::Formatter,
350
0
            ) -> $crate::__private::core::fmt::Result {
351
0
                let inner = self.0;
352
0
                $crate::__private::core::fmt::Octal::fmt(&inner, f)
353
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::fmt::Octal>::fmt
Unexecuted instantiation: <ron::extensions::Extensions as core::fmt::Octal>::fmt
354
        }
355
356
        $(#[$outer])*
357
        impl $crate::__private::core::fmt::LowerHex for $PublicBitFlags {
358
0
            fn fmt(
359
0
                &self,
360
0
                f: &mut $crate::__private::core::fmt::Formatter,
361
0
            ) -> $crate::__private::core::fmt::Result {
362
0
                let inner = self.0;
363
0
                $crate::__private::core::fmt::LowerHex::fmt(&inner, f)
364
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::fmt::LowerHex>::fmt
Unexecuted instantiation: <ron::extensions::Extensions as core::fmt::LowerHex>::fmt
365
        }
366
367
        $(#[$outer])*
368
        impl $crate::__private::core::fmt::UpperHex for $PublicBitFlags {
369
0
            fn fmt(
370
0
                &self,
371
0
                f: &mut $crate::__private::core::fmt::Formatter,
372
0
            ) -> $crate::__private::core::fmt::Result {
373
0
                let inner = self.0;
374
0
                $crate::__private::core::fmt::UpperHex::fmt(&inner, f)
375
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::fmt::UpperHex>::fmt
Unexecuted instantiation: <ron::extensions::Extensions as core::fmt::UpperHex>::fmt
376
        }
377
378
        $(#[$outer])*
379
        impl $crate::__private::core::ops::BitOr for $PublicBitFlags {
380
            type Output = Self;
381
382
            /// The bitwise or (`|`) of the bits in two flags values.
383
            #[inline]
384
1.38M
            fn bitor(self, other: $PublicBitFlags) -> Self {
385
1.38M
                self.union(other)
386
1.38M
            }
<ron::extensions::Extensions as core::ops::bit::BitOr>::bitor
Line
Count
Source
384
1.98k
            fn bitor(self, other: $PublicBitFlags) -> Self {
385
1.98k
                self.union(other)
386
1.98k
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::BitOr>::bitor
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::BitOr>::bitor
<ron::extensions::Extensions as core::ops::bit::BitOr>::bitor
Line
Count
Source
384
1.38M
            fn bitor(self, other: $PublicBitFlags) -> Self {
385
1.38M
                self.union(other)
386
1.38M
            }
387
        }
388
389
        $(#[$outer])*
390
        impl $crate::__private::core::ops::BitOrAssign for $PublicBitFlags {
391
            /// The bitwise or (`|`) of the bits in two flags values.
392
            #[inline]
393
295k
            fn bitor_assign(&mut self, other: Self) {
394
295k
                self.insert(other);
395
295k
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::BitOrAssign>::bitor_assign
<ron::extensions::Extensions as core::ops::bit::BitOrAssign>::bitor_assign
Line
Count
Source
393
295k
            fn bitor_assign(&mut self, other: Self) {
394
295k
                self.insert(other);
395
295k
            }
396
        }
397
398
        $(#[$outer])*
399
        impl $crate::__private::core::ops::BitXor for $PublicBitFlags {
400
            type Output = Self;
401
402
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
403
            #[inline]
404
0
            fn bitxor(self, other: Self) -> Self {
405
0
                self.symmetric_difference(other)
406
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::BitXor>::bitxor
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::BitXor>::bitxor
407
        }
408
409
        $(#[$outer])*
410
        impl $crate::__private::core::ops::BitXorAssign for $PublicBitFlags {
411
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
412
            #[inline]
413
0
            fn bitxor_assign(&mut self, other: Self) {
414
0
                self.toggle(other);
415
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::BitXorAssign>::bitxor_assign
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::BitXorAssign>::bitxor_assign
416
        }
417
418
        $(#[$outer])*
419
        impl $crate::__private::core::ops::BitAnd for $PublicBitFlags {
420
            type Output = Self;
421
422
            /// The bitwise and (`&`) of the bits in two flags values.
423
            #[inline]
424
17.1k
            fn bitand(self, other: Self) -> Self {
425
17.1k
                self.intersection(other)
426
17.1k
            }
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::BitAnd>::bitand
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::BitAnd>::bitand
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::BitAnd>::bitand
<ron::extensions::Extensions as core::ops::bit::BitAnd>::bitand
Line
Count
Source
424
17.1k
            fn bitand(self, other: Self) -> Self {
425
17.1k
                self.intersection(other)
426
17.1k
            }
427
        }
428
429
        $(#[$outer])*
430
        impl $crate::__private::core::ops::BitAndAssign for $PublicBitFlags {
431
            /// The bitwise and (`&`) of the bits in two flags values.
432
            #[inline]
433
0
            fn bitand_assign(&mut self, other: Self) {
434
0
                *self = Self::from_bits_retain(self.bits()).intersection(other);
435
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::BitAndAssign>::bitand_assign
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::BitAndAssign>::bitand_assign
436
        }
437
438
        $(#[$outer])*
439
        impl $crate::__private::core::ops::Sub for $PublicBitFlags {
440
            type Output = Self;
441
442
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
443
            ///
444
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
445
            /// `difference` won't truncate `other`, but the `!` operator will.
446
            #[inline]
447
0
            fn sub(self, other: Self) -> Self {
448
0
                self.difference(other)
449
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::arith::Sub>::sub
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::arith::Sub>::sub
450
        }
451
452
        $(#[$outer])*
453
        impl $crate::__private::core::ops::SubAssign for $PublicBitFlags {
454
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
455
            ///
456
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
457
            /// `difference` won't truncate `other`, but the `!` operator will.
458
            #[inline]
459
0
            fn sub_assign(&mut self, other: Self) {
460
0
                self.remove(other);
461
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::arith::SubAssign>::sub_assign
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::arith::SubAssign>::sub_assign
462
        }
463
464
        $(#[$outer])*
465
        impl $crate::__private::core::ops::Not for $PublicBitFlags {
466
            type Output = Self;
467
468
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
469
            #[inline]
470
17.1k
            fn not(self) -> Self {
471
17.1k
                self.complement()
472
17.1k
            }
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::Not>::not
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::ops::bit::Not>::not
Unexecuted instantiation: <ron::extensions::Extensions as core::ops::bit::Not>::not
<ron::extensions::Extensions as core::ops::bit::Not>::not
Line
Count
Source
470
17.1k
            fn not(self) -> Self {
471
17.1k
                self.complement()
472
17.1k
            }
473
        }
474
475
        $(#[$outer])*
476
        impl $crate::__private::core::iter::Extend<$PublicBitFlags> for $PublicBitFlags {
477
            /// The bitwise or (`|`) of the bits in each flags value.
478
0
            fn extend<T: $crate::__private::core::iter::IntoIterator<Item = Self>>(
479
0
                &mut self,
480
0
                iterator: T,
481
0
            ) {
482
0
                for item in iterator {
483
0
                    self.insert(item)
484
                }
485
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::iter::traits::collect::Extend<ron::extensions::_::InternalBitFlags>>::extend::<_>
Unexecuted instantiation: <ron::extensions::Extensions as core::iter::traits::collect::Extend<ron::extensions::Extensions>>::extend::<_>
486
0
        }
487
0
488
0
        $(#[$outer])*
489
0
        impl $crate::__private::core::iter::FromIterator<$PublicBitFlags> for $PublicBitFlags {
490
0
            /// The bitwise or (`|`) of the bits in each flags value.
491
0
            fn from_iter<T: $crate::__private::core::iter::IntoIterator<Item = Self>>(
492
0
                iterator: T,
493
0
            ) -> Self {
494
                use $crate::__private::core::iter::Extend;
495
496
0
                let mut result = Self::empty();
497
0
                result.extend(iterator);
498
0
                result
499
0
            }
Unexecuted instantiation: <ron::extensions::_::InternalBitFlags as core::iter::traits::collect::FromIterator<ron::extensions::_::InternalBitFlags>>::from_iter::<_>
Unexecuted instantiation: <ron::extensions::Extensions as core::iter::traits::collect::FromIterator<ron::extensions::Extensions>>::from_iter::<_>
500
        }
501
    };
502
}
503
504
/// Implement constants on the public (user-facing) bitflags type.
505
#[macro_export]
506
#[doc(hidden)]
507
macro_rules! __impl_public_bitflags_consts {
508
    (
509
        $(#[$outer:meta])*
510
        $PublicBitFlags:ident: $T:ty {
511
            $(
512
                $(#[$inner:ident $($args:tt)*])*
513
                const $Flag:tt = $value:expr;
514
            )*
515
        }
516
    ) => {
517
        $(#[$outer])*
518
        impl $PublicBitFlags {
519
            $(
520
                $crate::__bitflags_flag!({
521
                    name: $Flag,
522
                    named: {
523
                        $(#[$inner $($args)*])*
524
                        #[allow(
525
                            deprecated,
526
                            non_upper_case_globals,
527
                        )]
528
                        pub const $Flag: Self = Self::from_bits_retain($value);
529
                    },
530
                    unnamed: {},
531
                });
532
            )*
533
        }
534
535
        $(#[$outer])*
536
        impl $crate::Flags for $PublicBitFlags {
537
            const FLAGS: &'static [$crate::Flag<$PublicBitFlags>] = &[
538
                $(
539
                    $crate::__bitflags_flag!({
540
                        name: $Flag,
541
                        named: {
542
                            $crate::__bitflags_expr_safe_attrs!(
543
                                $(#[$inner $($args)*])*
544
                                {
545
                                    #[allow(
546
                                        deprecated,
547
                                        non_upper_case_globals,
548
                                    )]
549
                                    $crate::Flag::new($crate::__private::core::stringify!($Flag), $PublicBitFlags::$Flag)
550
                                }
551
                            )
552
                        },
553
                        unnamed: {
554
                            $crate::__bitflags_expr_safe_attrs!(
555
                                $(#[$inner $($args)*])*
556
                                {
557
                                    #[allow(
558
                                        deprecated,
559
                                        non_upper_case_globals,
560
                                    )]
561
                                    $crate::Flag::new("", $PublicBitFlags::from_bits_retain($value))
562
                                }
563
                            )
564
                        },
565
                    }),
566
                )*
567
            ];
568
569
            type Bits = $T;
570
571
875k
            fn bits(&self) -> $T {
572
875k
                $PublicBitFlags::bits(self)
573
875k
            }
574
575
492k
            fn from_bits_retain(bits: $T) -> $PublicBitFlags {
576
492k
                $PublicBitFlags::from_bits_retain(bits)
577
492k
            }
578
        }
579
    };
580
}