@@ -165,28 +165,23 @@ impl CStr16 {
165
165
}
166
166
}
167
167
168
- /// Write a string slice into the provided buffer. If it fails, then most probably, because
169
- /// the buffer is not big enough. In that case, the buffer will contain the correct string
170
- /// until the point, where the size was not enough.
168
+ /// Writes each [`Char16`] as a [´char´] (4 bytes long in Rust language) into the buffer.
169
+ /// It is up the the implementer of [`core::fmt::Write`] to convert the char to a string
170
+ /// with proper encoding/charset. For example, in the case of [`core::alloc::string::String`]
171
+ /// all Rust chars (UTF-32) get converted to UTF-8.
171
172
///
172
173
/// ## Example
173
174
///
174
- /// ```rust
175
- /// use uefi::data_types::ArrayString;
176
- /// use uefi::{CStr16, Char16};
175
+ /// ```ignore
177
176
/// let firmware_vendor_c16_str: CStr16 = ...;
178
- /// // crate "arrayvec" uses stack-allocated arrays for Strings => no heap
177
+ /// // crate "arrayvec" uses stack-allocated arrays for Strings => no heap allocations
179
178
/// let mut buf = arrayvec::ArrayString::<128>::new();
180
179
/// firmware_vendor_c16_str.as_str_in_buf(&mut buf);
181
180
/// log::info!("as rust str: {}", buf.as_str());
182
181
/// ```
183
- pub fn as_str_in_buf ( & self , buf : & mut dyn core:: fmt:: Write ) -> Result < ( ) , ( ) > {
182
+ pub fn as_str_in_buf ( & self , buf : & mut dyn core:: fmt:: Write ) -> core :: fmt :: Result {
184
183
for c16 in self . iter ( ) {
185
- let res = buf. write_char ( char:: from ( * c16) ) ;
186
- if let Err ( err) = res {
187
- log:: error!( "Failed to write CStr16 as &str into buffer. Buffer too small? ({})" , err) ;
188
- return Err ( ( ) )
189
- }
184
+ buf. write_char ( char:: from ( * c16) ) ?;
190
185
}
191
186
Ok ( ( ) )
192
187
}
0 commit comments