File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1
1
# uefi - [ Unreleased]
2
2
3
+ ## Added
4
+ - Implemented ` PartialEq<char> ` for ` Char8 ` and ` Char16 ` .
5
+
3
6
# uefi - 0.26.0 (2023-11-12)
4
7
5
8
## Added
Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ impl fmt::Display for Char8 {
66
66
}
67
67
}
68
68
69
+ impl PartialEq < char > for Char8 {
70
+ fn eq ( & self , other : & char ) -> bool {
71
+ u32:: from ( self . 0 ) == u32:: from ( * other)
72
+ }
73
+ }
74
+
69
75
/// Latin-1 version of the NUL character
70
76
pub const NUL_8 : Char8 = Char8 ( 0 ) ;
71
77
@@ -150,5 +156,24 @@ impl fmt::Display for Char16 {
150
156
}
151
157
}
152
158
159
+ impl PartialEq < char > for Char16 {
160
+ fn eq ( & self , other : & char ) -> bool {
161
+ u32:: from ( self . 0 ) == u32:: from ( * other)
162
+ }
163
+ }
164
+
153
165
/// UCS-2 version of the NUL character
154
166
pub const NUL_16 : Char16 = unsafe { Char16 :: from_u16_unchecked ( 0 ) } ;
167
+
168
+ #[ cfg( test) ]
169
+ mod tests {
170
+ use super :: * ;
171
+
172
+ /// Test that `Char8` and `Char16` can be directly compared with `char`.
173
+ #[ test]
174
+ fn test_char_eq ( ) {
175
+ let primitive_char: char = 'A' ;
176
+ assert_eq ! ( Char8 ( 0x41 ) , primitive_char) ;
177
+ assert_eq ! ( Char16 ( 0x41 ) , primitive_char) ;
178
+ }
179
+ }
You can’t perform that action at this time.
0 commit comments