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