Lines Matching defs:flags

11 //! A typesafe bitmask flag generator useful for sets of C-style bitmask flags.
14 //! The `bitflags!` macro generates `struct`s that manage a set of flags. The
15 //! flags should only be defined for integer types, otherwise unexpected type
74 //! let mut flags = Flags::A | Flags::B;
75 //! flags.clear();
76 //! assert!(flags.is_empty());
77 //! assert_eq!(format!("{}", flags), "hi!");
162 //! - `empty`: an empty set of flags
163 //! - `all`: the set of all defined flags
164 //! - `bits`: the raw value of the flags currently stored
169 //! any bits that do not correspond to defined flags
172 //! flags)
173 //! - `is_empty`: `true` if no flags are currently stored
174 //! - `is_all`: `true` if currently set flags exactly equal all defined flags
175 //! - `intersects`: `true` if there are flags common to both `self` and `other`
176 //! - `contains`: `true` if all of the flags in `other` are contained within `self`
177 //! - `insert`: inserts the specified flags in-place
178 //! - `remove`: removes the specified flags in-place
179 //! - `toggle`: the specified flags will be inserted if not present, and removed
181 //! - `set`: inserts or removes the specified flags depending on the passed value
182 //! - `intersection`: returns a new set of flags, containing only the flags present
184 //! - `union`: returns a new set of flags, containing any flags present in
186 //! - `difference`: returns a new set of flags, containing all flags present in
187 //! `self` without any of the flags present in `other` (the
189 //! - `symmetric_difference`: returns a new set of flags, containing all flags
192 //! - `complement`: returns a new set of flags, containing all flags which are
266 //! // Zero flags are treated as always present
271 //! // Zero flags will be ignored when testing for emptiness
341 /// let mut flags = Flags::A | Flags::B;
342 /// flags.clear();
343 /// assert!(flags.is_empty());
344 /// assert_eq!(format!("{}", flags), "hi!");
451 // Conditionally override the check for just those flags that
524 /// Returns an empty set of flags.
530 /// Returns the set containing all flags.
543 /// Returns the raw value of the flags currently stored.
561 /// that do not correspond to flags.
583 /// Returns `true` if no flags are currently stored.
589 /// Returns `true` if all flags are currently set.
595 /// Returns `true` if there are flags common to both `self` and `other`.
601 /// Returns `true` if all of the flags in `other` are contained within `self`.
607 /// Inserts the specified flags in-place.
613 /// Removes the specified flags in-place.
619 /// Toggles the specified flags in-place.
625 /// Inserts or removes the specified flags depending on the passed value.
635 /// Returns the intersection between the flags in `self` and
638 /// Specifically, the returned set contains only the flags which are
642 /// [`ops::BitAnd`]), as in `flags & other`.
651 /// Returns the union of between the flags in `self` and `other`.
653 /// Specifically, the returned set contains all flags which are
659 /// [`ops::BitOr`]), as in `flags | other`.
668 /// Returns the difference between the flags in `self` and `other`.
670 /// Specifically, the returned set contains all flags present in
674 /// `flags & !other` (and this syntax is also supported).
677 /// [`ops::Sub`]), as in `flags - other`.
686 /// Returns the [symmetric difference][sym-diff] between the flags
689 /// Specifically, the returned set contains the flags present which
691 /// both. Equivalently, it contains the flags present in *exactly
695 /// [`ops::BitXor`]), as in `flags ^ other`.
705 /// Returns the complement of this set of flags.
707 /// Specifically, the returned set contains all the flags which are
714 /// [`ops::Not`]), as in `!flags`.
729 /// Returns the union of the two sets of flags.
737 /// Adds the set of flags.
747 /// Returns the left flags, but with all the right flags toggled.
755 /// Toggles the set of flags.
765 /// Returns the intersection between the two sets of flags.
773 /// Disables all flags disabled in the set.
783 /// Returns the set difference of the two sets of flags.
791 /// Disables all flags enabled in the set.
801 /// Returns the complement of this set of flags.
1259 // especially around "unknown" flags (e.g. ones outside of `all()`
1261 // - when lhs and rhs both have different sets of unknown flags.
1262 // - unknown flags at both ends, and in the middle
1408 let mut flags;
1410 flags = Flags::empty();
1411 flags.extend([].iter().cloned());
1412 assert_eq!(flags, Flags::empty());
1414 flags = Flags::empty();
1415 flags.extend([Flags::A, Flags::B].iter().cloned());
1416 assert_eq!(flags, Flags::A | Flags::B);
1418 flags = Flags::A;
1419 flags.extend([Flags::A, Flags::B].iter().cloned());
1420 assert_eq!(flags, Flags::A | Flags::B);
1422 flags = Flags::B;
1423 flags.extend([Flags::A, Flags::ABC].iter().cloned());
1424 assert_eq!(flags, Flags::ABC);
1695 let flags = SerdeFlags::A | SerdeFlags::B;
1697 let serialized = serde_json::to_string(&flags).unwrap();
1713 let flags = SerdeFlags::A | SerdeFlags::B;
1715 let deserialized: SerdeFlags = serde_json::from_str(&serde_json::to_string(&flags).unwrap()).unwrap();
1717 assert_eq!(deserialized.bits, flags.bits);