@@ -18,52 +18,22 @@ pub use self::kvec::KVec;
1818pub use self :: kvec:: VVec ;
1919pub use self :: kvec:: Vec ;
2020
21+ use crate :: types:: declare_flags_type;
22+
2123/// Indicates an allocation error.
2224#[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
2325pub struct AllocError ;
2426
2527use crate :: error:: { code:: EINVAL , Result } ;
2628use core:: { alloc:: Layout , ptr:: NonNull } ;
2729
28- /// Flags to be used when allocating memory.
29- ///
30- /// They can be combined with the operators `|`, `&`, and `!`.
31- ///
32- /// Values can be used from the [`flags`] module.
33- #[ derive( Clone , Copy , PartialEq ) ]
34- pub struct Flags ( u32 ) ;
35-
36- impl Flags {
37- /// Get the raw representation of this flag.
38- pub ( crate ) fn as_raw ( self ) -> u32 {
39- self . 0
40- }
41-
42- /// Check whether `flags` is contained in `self`.
43- pub fn contains ( self , flags : Flags ) -> bool {
44- ( self & flags) == flags
45- }
46- }
47-
48- impl core:: ops:: BitOr for Flags {
49- type Output = Self ;
50- fn bitor ( self , rhs : Self ) -> Self :: Output {
51- Self ( self . 0 | rhs. 0 )
52- }
53- }
54-
55- impl core:: ops:: BitAnd for Flags {
56- type Output = Self ;
57- fn bitand ( self , rhs : Self ) -> Self :: Output {
58- Self ( self . 0 & rhs. 0 )
59- }
60- }
61-
62- impl core:: ops:: Not for Flags {
63- type Output = Self ;
64- fn not ( self ) -> Self :: Output {
65- Self ( !self . 0 )
66- }
30+ declare_flags_type ! {
31+ /// Flags to be used when allocating memory.
32+ ///
33+ /// They can be combined with the operators `|`, `&`, and `!`.
34+ ///
35+ /// Values can be used from the [`flags`] module.
36+ pub struct Flags ( u32 ) ;
6737}
6838
6939/// Allocation flags.
0 commit comments