@@ -25,50 +25,20 @@ pub use self::kvec::KVec;
2525pub use self :: kvec:: VVec ;
2626pub use self :: kvec:: Vec ;
2727
28+ use crate :: types:: declare_flags_type;
29+
2830/// Indicates an allocation error.
2931#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
3032pub struct AllocError ;
3133use core:: { alloc:: Layout , ptr:: NonNull } ;
3234
33- /// Flags to be used when allocating memory.
34- ///
35- /// They can be combined with the operators `|`, `&`, and `!`.
36- ///
37- /// Values can be used from the [`flags`] module.
38- #[ derive( Clone , Copy , PartialEq ) ]
39- pub struct Flags ( u32 ) ;
40-
41- impl Flags {
42- /// Get the raw representation of this flag.
43- pub ( crate ) fn as_raw ( self ) -> u32 {
44- self . 0
45- }
46-
47- /// Check whether `flags` is contained in `self`.
48- pub fn contains ( self , flags : Flags ) -> bool {
49- ( self & flags) == flags
50- }
51- }
52-
53- impl core:: ops:: BitOr for Flags {
54- type Output = Self ;
55- fn bitor ( self , rhs : Self ) -> Self :: Output {
56- Self ( self . 0 | rhs. 0 )
57- }
58- }
59-
60- impl core:: ops:: BitAnd for Flags {
61- type Output = Self ;
62- fn bitand ( self , rhs : Self ) -> Self :: Output {
63- Self ( self . 0 & rhs. 0 )
64- }
65- }
66-
67- impl core:: ops:: Not for Flags {
68- type Output = Self ;
69- fn not ( self ) -> Self :: Output {
70- Self ( !self . 0 )
71- }
35+ declare_flags_type ! {
36+ /// Flags to be used when allocating memory.
37+ ///
38+ /// They can be combined with the operators `|`, `&`, and `!`.
39+ ///
40+ /// Values can be used from the [`flags`] module.
41+ pub struct Flags ( u32 ) ;
7242}
7343
7444/// Allocation flags.
0 commit comments