4
4
// SPDX-License-Identifier: MIT OR Apache-2.0
5
5
6
6
use cxx:: ExternType ;
7
- use std:: fmt:: Debug ;
8
- use std:: hash:: Hash ;
7
+ use std:: fmt:: { self , Debug , Formatter } ;
8
+ use std:: hash:: { Hash , Hasher } ;
9
9
use std:: ops:: { BitAnd , BitAndAssign , BitOr , BitOrAssign , BitXor , BitXorAssign , Not } ;
10
10
11
11
mod qflag;
@@ -19,7 +19,6 @@ mod util;
19
19
20
20
/// The `QFlags<T>` class is a template class, where T is an enum type.
21
21
/// QFlags are used throughout Qt for storing combinations of enum values.
22
- #[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
23
22
#[ repr( transparent) ]
24
23
pub struct QFlags < T : QFlag > {
25
24
repr : <T :: Repr as QFlagRepr >:: Int ,
@@ -33,6 +32,38 @@ impl<T: QFlag> Clone for QFlags<T> {
33
32
}
34
33
}
35
34
35
+ impl < T : QFlag > Debug for QFlags < T > {
36
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
37
+ f. debug_struct ( "QFlags" ) . field ( "repr" , & self . repr ) . finish ( )
38
+ }
39
+ }
40
+
41
+ impl < T : QFlag > PartialEq for QFlags < T > {
42
+ fn eq ( & self , other : & Self ) -> bool {
43
+ self . repr == other. repr
44
+ }
45
+ }
46
+
47
+ impl < T : QFlag > Eq for QFlags < T > { }
48
+
49
+ impl < T : QFlag > PartialOrd for QFlags < T > {
50
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
51
+ Some ( self . cmp ( other) )
52
+ }
53
+ }
54
+
55
+ impl < T : QFlag > Ord for QFlags < T > {
56
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
57
+ self . repr . cmp ( & other. repr )
58
+ }
59
+ }
60
+
61
+ impl < T : QFlag > Hash for QFlags < T > {
62
+ fn hash < H : Hasher > ( & self , state : & mut H ) {
63
+ self . repr . hash ( state) ;
64
+ }
65
+ }
66
+
36
67
impl < T : QFlag > From < T > for QFlags < T > {
37
68
/// Returns the value stored in the QFlags object as an integer.
38
69
fn from ( value : T ) -> Self {
0 commit comments