File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1616- ` boot::allocate_pages ` no longer panics if the allocation is at address
1717 zero. The allocation is retried instead, and in all failure cases an error is
1818 returned rather than panicking.
19+ - The ` Display ` impl for ` CStr8 ` now excludes the trailing null character.
1920
2021
2122# uefi - 0.34.1 (2025-02-07)
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ impl fmt::Debug for CStr8 {
196196
197197impl fmt:: Display for CStr8 {
198198 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
199- for c in self . 0 . iter ( ) {
199+ for c in & self . 0 [ .. & self . 0 . len ( ) - 1 ] {
200200 <Char8 as fmt:: Display >:: fmt ( c, f) ?;
201201 }
202202 Ok ( ( ) )
@@ -763,6 +763,7 @@ where
763763mod tests {
764764 use super :: * ;
765765 use crate :: { cstr16, cstr8} ;
766+ use alloc:: format;
766767 use alloc:: string:: String ;
767768
768769 // Tests if our CStr8 type can be constructed from a valid core::ffi::CStr
@@ -783,6 +784,18 @@ mod tests {
783784 assert_eq ! ( <CStr8 as Borrow <[ u8 ] >>:: borrow( string) , & [ b'a' , 0 ] ) ;
784785 }
785786
787+ #[ test]
788+ fn test_cstr8_display ( ) {
789+ let s = cstr8 ! ( "abc" ) ;
790+ assert_eq ! ( format!( "{s}" ) , "abc" ) ;
791+ }
792+
793+ #[ test]
794+ fn test_cstr16_display ( ) {
795+ let s = cstr16 ! ( "abc" ) ;
796+ assert_eq ! ( format!( "{s}" ) , "abc" ) ;
797+ }
798+
786799 #[ test]
787800 fn test_cstr16_num_bytes ( ) {
788801 let s = CStr16 :: from_u16_with_nul ( & [ 65 , 66 , 67 , 0 ] ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments