1const CONST1: u32 = 0b10;
7const CONST2: u32 = 0b100;
8
9mod namespaced {
10 pub const CONST3: u32 = 0b1000;
11 pub const FLAG1: u32 = super::ExampleFlags::Flag1.bits();
12}
13
14#[repr(transparent)]
15#[doc = " A example bitflag"]
16#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
17pub struct ExampleFlags(u32)
18where
19 u32: crate::BitsPrimitive;
20
21#[doc(hidden)]
22#[allow(clippy::unused_unit)]
23const _: () = {
24 {
25 #[allow(dead_code)]
26 #[doc = " A example bitflag"]
27 enum ExampleFlags {
28 Flag1,
29 Flag2,
30 Flag3,
31 Flag4,
32 Flag5,
33 Flag6,
34 Flag7,
35 Flag8,
36 Flag9,
37 Flag10,
38 Flag11,
39 Flag12,
40 }
41 }
42 ()
43};
44#[allow(non_upper_case_globals)]
45impl ExampleFlags {
46 pub const Flag1: Self = Self(1 << 9);
47 pub const Flag2: Self = Self(1 << 12);
48 pub const Flag3: Self = Self(CONST1);
49 pub const Flag4: Self = Self(!CONST1);
50 pub const Flag5: Self = Self(CONST1 | CONST2 | 3);
51 pub const Flag6: Self = {
52 #[allow(non_upper_case_globals, dead_code, unused)]
53 const Flag1: u32 = 1 << 9;
54 #[allow(non_upper_case_globals, dead_code, unused)]
55 const Flag2: u32 = 1 << 12;
56 #[allow(non_upper_case_globals, dead_code, unused)]
57 const Flag3: u32 = CONST1;
58 #[allow(non_upper_case_globals, dead_code, unused)]
59 const Flag4: u32 = !CONST1;
60 #[allow(non_upper_case_globals, dead_code, unused)]
61 const Flag5: u32 = CONST1 | CONST2 | 3;
62 #[allow(non_upper_case_globals, dead_code, unused)]
63 const Flag6: u32 = Flag1 | Flag2;
64 #[allow(non_upper_case_globals, dead_code, unused)]
65 const Flag7: u32 = CONST1 | Flag1;
66 #[allow(non_upper_case_globals, dead_code, unused)]
67 const Flag8: u32 = (1 << 1) | (1 << 4);
68 #[allow(non_upper_case_globals, dead_code, unused)]
69 const Flag9: u32 = 1u8 as u32;
70 #[allow(non_upper_case_globals, dead_code, unused)]
71 const Flag10: u32 = ExampleFlags::Flag1.bits() | ExampleFlags::Flag4.bits();
72 #[allow(non_upper_case_globals, dead_code, unused)]
73 const Flag11: u32 = namespaced::CONST3;
74 #[allow(non_upper_case_globals, dead_code, unused)]
75 const Flag12: u32 = namespaced::CONST3 & namespaced::FLAG1;
76 Self(Flag1 | Flag2)
77 };
78 pub const Flag7: Self = {
79 #[allow(non_upper_case_globals, dead_code, unused)]
80 const Flag1: u32 = 1 << 9;
81 #[allow(non_upper_case_globals, dead_code, unused)]
82 const Flag2: u32 = 1 << 12;
83 #[allow(non_upper_case_globals, dead_code, unused)]
84 const Flag3: u32 = CONST1;
85 #[allow(non_upper_case_globals, dead_code, unused)]
86 const Flag4: u32 = !CONST1;
87 #[allow(non_upper_case_globals, dead_code, unused)]
88 const Flag5: u32 = CONST1 | CONST2 | 3;
89 #[allow(non_upper_case_globals, dead_code, unused)]
90 const Flag6: u32 = Flag1 | Flag2;
91 #[allow(non_upper_case_globals, dead_code, unused)]
92 const Flag7: u32 = CONST1 | Flag1;
93 #[allow(non_upper_case_globals, dead_code, unused)]
94 const Flag8: u32 = (1 << 1) | (1 << 4);
95 #[allow(non_upper_case_globals, dead_code, unused)]
96 const Flag9: u32 = 1u8 as u32;
97 #[allow(non_upper_case_globals, dead_code, unused)]
98 const Flag10: u32 = ExampleFlags::Flag1.bits() | ExampleFlags::Flag4.bits();
99 #[allow(non_upper_case_globals, dead_code, unused)]
100 const Flag11: u32 = namespaced::CONST3;
101 #[allow(non_upper_case_globals, dead_code, unused)]
102 const Flag12: u32 = namespaced::CONST3 & namespaced::FLAG1;
103 Self(CONST1 | Flag1)
104 };
105 pub const Flag8: Self = Self((1 << 1) | (1 << 4));
106 pub const Flag9: Self = Self(1u8 as u32);
107 pub const Flag10: Self = {
108 #[allow(non_upper_case_globals, dead_code, unused)]
109 const Flag1: u32 = 1 << 9;
110 #[allow(non_upper_case_globals, dead_code, unused)]
111 const Flag2: u32 = 1 << 12;
112 #[allow(non_upper_case_globals, dead_code, unused)]
113 const Flag3: u32 = CONST1;
114 #[allow(non_upper_case_globals, dead_code, unused)]
115 const Flag4: u32 = !CONST1;
116 #[allow(non_upper_case_globals, dead_code, unused)]
117 const Flag5: u32 = CONST1 | CONST2 | 3;
118 #[allow(non_upper_case_globals, dead_code, unused)]
119 const Flag6: u32 = Flag1 | Flag2;
120 #[allow(non_upper_case_globals, dead_code, unused)]
121 const Flag7: u32 = CONST1 | Flag1;
122 #[allow(non_upper_case_globals, dead_code, unused)]
123 const Flag8: u32 = (1 << 1) | (1 << 4);
124 #[allow(non_upper_case_globals, dead_code, unused)]
125 const Flag9: u32 = 1u8 as u32;
126 #[allow(non_upper_case_globals, dead_code, unused)]
127 const Flag10: u32 = ExampleFlags::Flag1.bits() | ExampleFlags::Flag4.bits();
128 #[allow(non_upper_case_globals, dead_code, unused)]
129 const Flag11: u32 = namespaced::CONST3;
130 #[allow(non_upper_case_globals, dead_code, unused)]
131 const Flag12: u32 = namespaced::CONST3 & namespaced::FLAG1;
132 Self(ExampleFlags::Flag1.bits() | ExampleFlags::Flag4.bits())
133 };
134 pub const Flag11: Self = Self(namespaced::CONST3);
135 pub const Flag12: Self = Self(namespaced::CONST3 & namespaced::FLAG1);
136}
137#[allow(non_upper_case_globals)]
138impl ExampleFlags {
139 #[doc = r" Return the underlying bits of this bitflag."]
140 #[inline]
141 pub const fn bits(&self) -> u32 {
142 self.0
143 }
144 #[doc = r" Converts from a `bits` value. Returning [`None`] is any unknown bits are set."]
145 #[inline]
146 pub const fn from_bits(bits: u32) -> ::core::option::Option<Self> {
147 let truncated = Self::from_bits_truncate(bits).0;
148 if truncated == bits {
149 ::core::option::Option::Some(Self(bits))
150 } else {
151 ::core::option::Option::None
152 }
153 }
154 #[doc = r" Convert from `bits` value, unsetting any unknown bits."]
155 #[inline]
156 pub const fn from_bits_truncate(bits: u32) -> Self {
157 Self(bits & Self::all().0)
158 }
159 #[doc = r" Convert from `bits` value exactly."]
160 #[inline]
161 pub const fn from_bits_retain(bits: u32) -> Self {
162 Self(bits)
163 }
164 #[doc = r" Convert from a flag `name`."]
165 #[inline]
166 pub fn from_flag_name(name: &str) -> ::core::option::Option<Self> {
167 match name {
168 "Flag1" => ::core::option::Option::Some(ExampleFlags::Flag1),
169 "Flag2" => ::core::option::Option::Some(ExampleFlags::Flag2),
170 "Flag3" => ::core::option::Option::Some(ExampleFlags::Flag3),
171 "Flag4" => ::core::option::Option::Some(ExampleFlags::Flag4),
172 "Flag5" => ::core::option::Option::Some(ExampleFlags::Flag5),
173 "Flag6" => ::core::option::Option::Some(ExampleFlags::Flag6),
174 "Flag7" => ::core::option::Option::Some(ExampleFlags::Flag7),
175 "Flag8" => ::core::option::Option::Some(ExampleFlags::Flag8),
176 "Flag9" => ::core::option::Option::Some(ExampleFlags::Flag9),
177 "Flag10" => ::core::option::Option::Some(ExampleFlags::Flag10),
178 "Flag11" => ::core::option::Option::Some(ExampleFlags::Flag11),
179 "Flag12" => ::core::option::Option::Some(ExampleFlags::Flag12),
180 _ => ::core::option::Option::None,
181 }
182 }
183 #[doc = r" Construct a flags value with all bits unset."]
184 #[inline]
185 pub const fn empty() -> Self {
186 Self(0)
187 }
188 #[doc = r" Returns `true` if the flag value has all bits unset."]
189 #[inline]
190 pub const fn is_empty(&self) -> bool {
191 self.0 == 0
192 }
193 #[doc = r" Returns a flag value that contains all value."]
194 #[doc = r""]
195 #[doc = r" This will include bits that do not have any flags/meaning."]
196 #[doc = r" Use [`all`](Self::all) if you want only the specified flags set."]
197 #[inline]
198 pub const fn all_bits() -> Self {
199 Self(!0)
200 }
201 #[doc = r" Returns `true` if the flag value contains all value bits set."]
202 #[doc = r""]
203 #[doc = r" This will check for all bits."]
204 #[doc = r" Use [`is_all`](Self::is_all) if you want to check for all specified flags."]
205 #[inline]
206 pub const fn is_all_bits(&self) -> bool {
207 self.0 == !0
208 }
209 #[doc = r" Construct a flag value with all known flags set."]
210 #[doc = r""]
211 #[doc = r" This will only set the flags specified as associated constant and the defined"]
212 #[doc = r" extra valid bits."]
213 #[inline]
214 pub const fn all() -> Self {
215 let mut all = 0;
216 {
217 all |= ExampleFlags::Flag1.0;
218 }
219 {
220 all |= ExampleFlags::Flag2.0;
221 }
222 {
223 all |= ExampleFlags::Flag3.0;
224 }
225 {
226 all |= ExampleFlags::Flag4.0;
227 }
228 {
229 all |= ExampleFlags::Flag5.0;
230 }
231 {
232 all |= ExampleFlags::Flag6.0;
233 }
234 {
235 all |= ExampleFlags::Flag7.0;
236 }
237 {
238 all |= ExampleFlags::Flag8.0;
239 }
240 {
241 all |= ExampleFlags::Flag9.0;
242 }
243 {
244 all |= ExampleFlags::Flag10.0;
245 }
246 {
247 all |= ExampleFlags::Flag11.0;
248 }
249 {
250 all |= ExampleFlags::Flag12.0;
251 }
252 Self(all)
253 }
254 #[doc = r" Returns `true` if the flag value contais all known flags."]
255 #[inline]
256 pub const fn is_all(&self) -> bool {
257 Self::all().0 | self.0 == self.0
258 }
259 #[doc = r" Construct a flag value with all known named flags set."]
260 #[doc = r""]
261 #[doc = r" This will only set the flags specified as associated constant **without** the"]
262 #[doc = r" defined extra valid bits."]
263 #[inline]
264 pub const fn all_named() -> Self {
265 let mut all = 0;
266 {
267 all |= ExampleFlags::Flag1.0;
268 }
269 {
270 all |= ExampleFlags::Flag2.0;
271 }
272 {
273 all |= ExampleFlags::Flag3.0;
274 }
275 {
276 all |= ExampleFlags::Flag4.0;
277 }
278 {
279 all |= ExampleFlags::Flag5.0;
280 }
281 {
282 all |= ExampleFlags::Flag6.0;
283 }
284 {
285 all |= ExampleFlags::Flag7.0;
286 }
287 {
288 all |= ExampleFlags::Flag8.0;
289 }
290 {
291 all |= ExampleFlags::Flag9.0;
292 }
293 {
294 all |= ExampleFlags::Flag10.0;
295 }
296 {
297 all |= ExampleFlags::Flag11.0;
298 }
299 {
300 all |= ExampleFlags::Flag12.0;
301 }
302 Self(all)
303 }
304 #[doc = r" Returns `true` if the flag value contais all known named flags."]
305 #[inline]
306 pub const fn is_all_named(&self) -> bool {
307 Self::all_named().0 | self.0 == self.0
308 }
309 #[doc = r" Returns `true` if there are any unknown bits set in the flag value."]
310 #[inline]
311 pub const fn contains_unknown_bits(&self) -> bool {
312 Self::all().0 & self.0 != self.0
313 }
314 #[doc = r" Returns `true` if there are any unnamed known bits set in the flag value."]
315 #[inline]
316 pub const fn contains_unnamed_bits(&self) -> bool {
317 Self::all_named().0 & self.0 != self.0
318 }
319 #[doc = r" Returns a bit flag with unknown bits removed from the original value."]
320 #[inline]
321 pub const fn truncated(&self) -> Self {
322 Self(self.0 & Self::all().0)
323 }
324 #[doc = r" Removes unknown bits from the flag value."]
325 #[inline]
326 pub fn truncate(&mut self) {
327 *self = Self::from_bits_truncate(self.0);
328 }
329 #[doc = r" Returns `true` if this flag value intersects with any value in `other`."]
330 #[doc = r""]
331 #[doc = r" This is equivalent to `(self & other) != Self::empty()`"]
332 #[inline]
333 pub const fn intersects(&self, other: Self) -> bool {
334 (self.0 & other.0) != Self::empty().0
335 }
336 #[doc = r" Returns `true` if this flag value contains all values of `other`."]
337 #[doc = r""]
338 #[doc = r" This is equivalent to `(self & other) == other`"]
339 #[inline]
340 pub const fn contains(&self, other: Self) -> bool {
341 (self.0 & other.0) == other.0
342 }
343 #[doc = r" Returns the bitwise NOT of the flag."]
344 #[doc = r""]
345 #[doc = r" This function does not truncate unused bits (bits that do not have any flags/meaning)."]
346 #[doc = r" Use [`complement`](Self::complement) if you want that the result to be truncated in one call."]
347 #[inline]
348 #[doc(alias = "complement")]
349 pub const fn not(self) -> Self {
350 Self(!self.0)
351 }
352 #[doc = r" Returns the bitwise AND of the flag."]
353 #[inline]
354 #[doc(alias = "intersection")]
355 pub const fn and(self, other: Self) -> Self {
356 Self(self.0 & other.0)
357 }
358 #[doc = r" Returns the bitwise OR of the flag with `other`."]
359 #[inline]
360 #[doc(alias = "union")]
361 pub const fn or(self, other: Self) -> Self {
362 Self(self.0 | other.0)
363 }
364 #[doc = r" Returns the bitwise XOR of the flag with `other`."]
365 #[inline]
366 #[doc(alias = "symmetric_difference")]
367 pub const fn xor(self, other: Self) -> Self {
368 Self(self.0 ^ other.0)
369 }
370 #[doc = r" Returns the intersection from this value with `other`."]
371 #[inline]
372 #[doc(alias = "and")]
373 pub const fn intersection(self, other: Self) -> Self {
374 self.and(other)
375 }
376 #[doc = r" Returns the union from this value with `other`."]
377 #[inline]
378 #[doc(alias = "or")]
379 pub const fn union(self, other: Self) -> Self {
380 self.or(other)
381 }
382 #[doc = r" Returns the difference from this value with `other`."]
383 #[doc = r""]
384 #[doc = r" In other words, returns the intersection of this value with the negation of `other`."]
385 #[doc = r""]
386 #[doc = r" This method is not equivalent to `self & !other` when `other` has unknown bits set."]
387 #[doc = r" `difference` won't truncate `other`, but the `!` operator will."]
388 #[inline]
389 pub const fn difference(self, other: Self) -> Self {
390 self.and(other.not())
391 }
392 #[doc = r" Returns the symmetric difference from this value with `other`."]
393 #[inline]
394 #[doc(alias = "xor")]
395 pub const fn symmetric_difference(self, other: Self) -> Self {
396 self.xor(other)
397 }
398 #[doc = r" Returns the complement of the value."]
399 #[doc = r""]
400 #[doc = r" This is very similar to the [`not`](Self::not), but truncates non used bits."]
401 #[inline]
402 #[doc(alias = "not")]
403 pub const fn complement(self) -> Self {
404 self.not().truncated()
405 }
406 #[doc = r" Set the flags in `other` in the value."]
407 #[inline]
408 #[doc(alias = "insert")]
409 pub fn set(&mut self, other: Self) {
410 self.0 = self.or(other).0
411 }
412 #[doc = r" Unset the flags bits in `other` in the value."]
413 #[inline]
414 #[doc(alias = "remove")]
415 pub fn unset(&mut self, other: Self) {
416 self.0 = self.difference(other).0
417 }
418 #[doc = r" Toggle the flags in `other` in the value."]
419 #[inline]
420 pub fn toggle(&mut self, other: Self) {
421 self.0 = self.xor(other).0
422 }
423 #[doc = r" Resets the flags to a empty state."]
424 #[inline]
425 pub fn clear(&mut self) {
426 self.0 = 0
427 }
428}
429#[automatically_derived]
430impl ::core::ops::Not for ExampleFlags {
431 type Output = Self;
432 #[inline]
433 fn not(self) -> Self::Output {
434 self.complement()
435 }
436}
437#[automatically_derived]
438impl ::core::ops::BitAnd for ExampleFlags {
439 type Output = Self;
440 #[inline]
441 fn bitand(self, rhs: Self) -> Self::Output {
442 self.and(rhs)
443 }
444}
445#[automatically_derived]
446impl ::core::ops::BitOr for ExampleFlags {
447 type Output = Self;
448 #[inline]
449 fn bitor(self, rhs: Self) -> Self::Output {
450 self.or(rhs)
451 }
452}
453#[automatically_derived]
454impl ::core::ops::BitXor for ExampleFlags {
455 type Output = Self;
456 #[inline]
457 fn bitxor(self, rhs: Self) -> Self::Output {
458 self.xor(rhs)
459 }
460}
461#[automatically_derived]
462impl ::core::ops::BitAndAssign for ExampleFlags {
463 #[inline]
464 fn bitand_assign(&mut self, rhs: Self) {
465 *self = self.and(rhs)
466 }
467}
468#[automatically_derived]
469impl ::core::ops::BitOrAssign for ExampleFlags {
470 #[inline]
471 fn bitor_assign(&mut self, rhs: Self) {
472 *self = self.or(rhs)
473 }
474}
475#[automatically_derived]
476impl ::core::ops::BitXorAssign for ExampleFlags {
477 #[inline]
478 fn bitxor_assign(&mut self, rhs: Self) {
479 *self = self.xor(rhs)
480 }
481}
482#[automatically_derived]
483impl ::core::ops::Sub for ExampleFlags {
484 type Output = Self;
485 #[doc = r" The intersection of a source flag with the complement of a target flags value"]
486 #[inline]
487 fn sub(self, rhs: Self) -> Self::Output {
488 self.difference(rhs)
489 }
490}
491#[automatically_derived]
492impl ::core::ops::SubAssign for ExampleFlags {
493 #[doc = r" The intersection of a source flag with the complement of a target flags value"]
494 #[inline]
495 fn sub_assign(&mut self, rhs: Self) {
496 self.unset(rhs)
497 }
498}
499#[automatically_derived]
500impl ::core::convert::From<u32> for ExampleFlags {
501 #[inline]
502 fn from(val: u32) -> Self {
503 Self::from_bits_truncate(val)
504 }
505}
506#[automatically_derived]
507impl ::core::convert::From<ExampleFlags> for u32 {
508 #[inline]
509 fn from(val: ExampleFlags) -> Self {
510 val.0
511 }
512}
513#[automatically_derived]
514impl ::core::fmt::Binary for ExampleFlags {
515 #[inline]
516 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
517 ::core::fmt::Binary::fmt(&self.0, f)
518 }
519}
520#[automatically_derived]
521impl ::core::fmt::LowerHex for ExampleFlags {
522 #[inline]
523 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
524 ::core::fmt::LowerHex::fmt(&self.0, f)
525 }
526}
527#[automatically_derived]
528impl ::core::fmt::UpperHex for ExampleFlags {
529 #[inline]
530 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
531 ::core::fmt::UpperHex::fmt(&self.0, f)
532 }
533}
534#[automatically_derived]
535impl ::core::fmt::Octal for ExampleFlags {
536 #[inline]
537 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
538 ::core::fmt::Octal::fmt(&self.0, f)
539 }
540}
541#[automatically_derived]
542impl ::core::str::FromStr for ExampleFlags {
543 type Err = crate::parser::ParseError;
544 #[inline]
545 fn from_str(input: &str) -> ::core::result::Result<Self, Self::Err> {
546 crate::parser::from_text(input)
547 }
548}
549#[automatically_derived]
550impl ::core::fmt::Debug for ExampleFlags {
551 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
552 struct HumanReadable<'a>(&'a ExampleFlags);
553
554 impl<'a> ::core::fmt::Debug for HumanReadable<'a> {
555 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
556 if self.0.is_empty() {
557 f.write_fmt(core::format_args!("{:#X}", self.0 .0))
558 } else {
559 crate::parser::to_writer(self.0, f)
560 }
561 }
562 }
563 #[inline]
564 pub const fn octal_width() -> usize {
565 match u32::BITS as usize {
566 8 => 3,
567 16 => 6,
568 32 => 11,
569 64 => 22,
570 128 => 43,
571 x => x / 3 + x % 3,
572 }
573 }
574 let name = "ExampleFlags";
575 f.debug_struct(name)
576 .field("flags", &HumanReadable(self))
577 .field(
578 "bits",
579 &::core::format_args!("{:#0width$b}", self.0, width = 2 + u32::BITS as usize),
580 )
581 .field(
582 "octal",
583 &::core::format_args!("{:#0width$o}", self.0, width = 2 + const { octal_width() }),
584 )
585 .field(
586 "hex",
587 &::core::format_args!(
588 "{:#0width$X}",
589 self.0,
590 width = 2 + const { u32::BITS as usize / 4 }
591 ),
592 )
593 .finish()
594 }
595}
596#[automatically_derived]
597impl crate::Flags for ExampleFlags {
598 const NAMED_FLAGS: &'static [(&'static str, ExampleFlags)] = &[
599 ("Flag1", ExampleFlags::Flag1),
600 ("Flag2", ExampleFlags::Flag2),
601 ("Flag3", ExampleFlags::Flag3),
602 ("Flag4", ExampleFlags::Flag4),
603 ("Flag5", ExampleFlags::Flag5),
604 ("Flag6", ExampleFlags::Flag6),
605 ("Flag7", ExampleFlags::Flag7),
606 ("Flag8", ExampleFlags::Flag8),
607 ("Flag9", ExampleFlags::Flag9),
608 ("Flag10", ExampleFlags::Flag10),
609 ("Flag11", ExampleFlags::Flag11),
610 ("Flag12", ExampleFlags::Flag12),
611 ];
612 const RESERVED_BITS: u32 = {
613 let mut all = 0;
614 {
615 all |= ExampleFlags::Flag1.0;
616 }
617 {
618 all |= ExampleFlags::Flag2.0;
619 }
620 {
621 all |= ExampleFlags::Flag3.0;
622 }
623 {
624 all |= ExampleFlags::Flag4.0;
625 }
626 {
627 all |= ExampleFlags::Flag5.0;
628 }
629 {
630 all |= ExampleFlags::Flag6.0;
631 }
632 {
633 all |= ExampleFlags::Flag7.0;
634 }
635 {
636 all |= ExampleFlags::Flag8.0;
637 }
638 {
639 all |= ExampleFlags::Flag9.0;
640 }
641 {
642 all |= ExampleFlags::Flag10.0;
643 }
644 {
645 all |= ExampleFlags::Flag11.0;
646 }
647 {
648 all |= ExampleFlags::Flag12.0;
649 }
650 all
651 };
652 type Bits = u32;
653 #[inline]
654 fn bits(&self) -> Self::Bits {
655 self.0
656 }
657 #[inline]
658 fn from_bits_retain(bits: Self::Bits) -> Self {
659 Self(bits)
660 }
661}
662impl ExampleFlags {
663 const NAMED_FLAGS: &'static [(&'static str, ExampleFlags)] = &[
664 ("Flag1", ExampleFlags::Flag1),
665 ("Flag2", ExampleFlags::Flag2),
666 ("Flag3", ExampleFlags::Flag3),
667 ("Flag4", ExampleFlags::Flag4),
668 ("Flag5", ExampleFlags::Flag5),
669 ("Flag6", ExampleFlags::Flag6),
670 ("Flag7", ExampleFlags::Flag7),
671 ("Flag8", ExampleFlags::Flag8),
672 ("Flag9", ExampleFlags::Flag9),
673 ("Flag10", ExampleFlags::Flag10),
674 ("Flag11", ExampleFlags::Flag11),
675 ("Flag12", ExampleFlags::Flag12),
676 ];
677 #[doc = r" Yield a set of contained flags values."]
678 #[doc = r""]
679 #[doc = r" Each yielded flags value will correspond to a defined named flag. Any unknown bits"]
680 #[doc = r" will be yielded together as a final flags value."]
681 #[inline]
682 pub const fn iter(&self) -> crate::iter::Iter<Self> {
683 crate::iter::Iter::__private_const_new(Self::NAMED_FLAGS, *self, *self)
684 }
685 #[doc = r" Yield a set of contained named flags values."]
686 #[doc = r""]
687 #[doc = r" This method is like [`iter`](#method.iter), except only yields bits in contained named flags."]
688 #[doc = r" Any unknown bits, or bits not corresponding to a contained flag will not be yielded."]
689 #[inline]
690 pub const fn iter_names(&self) -> crate::iter::IterNames<Self> {
691 crate::iter::IterNames::__private_const_new(Self::NAMED_FLAGS, *self, *self)
692 }
693}
694#[automatically_derived]
695impl ::core::iter::Extend<ExampleFlags> for ExampleFlags {
696 #[doc = r" Set all flags of `iter` to self"]
697 fn extend<T: ::core::iter::IntoIterator<Item = Self>>(&mut self, iter: T) {
698 for item in iter {
699 self.set(item);
700 }
701 }
702}
703#[automatically_derived]
704impl ::core::iter::FromIterator<ExampleFlags> for ExampleFlags {
705 #[doc = "Create a `ExampleFlags` from a iterator of flags."]
706 fn from_iter<T: ::core::iter::IntoIterator<Item = Self>>(iter: T) -> Self {
707 use ::core::iter::Extend;
708 let mut res = Self::empty();
709 res.extend(iter);
710 res
711 }
712}
713#[automatically_derived]
714impl ::core::iter::IntoIterator for ExampleFlags {
715 type Item = Self;
716 type IntoIter = crate::iter::Iter<Self>;
717 #[inline]
718 fn into_iter(self) -> Self::IntoIter {
719 self.iter()
720 }
721}
722#[automatically_derived]
723impl ::core::iter::IntoIterator for &ExampleFlags {
724 type Item = ExampleFlags;
725 type IntoIter = crate::iter::Iter<ExampleFlags>;
726 #[inline]
727 fn into_iter(self) -> Self::IntoIter {
728 self.iter()
729 }
730}