diff --git a/src/f_string.rs b/src/f_string.rs index 96051a3..75165b5 100644 --- a/src/f_string.rs +++ b/src/f_string.rs @@ -38,12 +38,12 @@ impl Printf for FString { #[inline(always)] fn printf_unsafe>(&mut self, fmt: A) { let tmp = U16CString::from_str(fmt).unwrap(); - let new_len = tmp.len(); + let mut tmp_bytes = tmp.into_vec_with_nul(); + let new_len = tmp_bytes.len(); if new_len > self.0.cap as usize { // TODO: use Result instead panic!("New string is too long and no printf ffi binding has been provided"); } - let mut tmp_bytes = tmp.into_vec_with_nul(); tmp_bytes.resize(self.0.cap as usize, 0); unsafe { std::ptr::copy_nonoverlapping(