diff --git a/src/util.rs b/src/util.rs index 884ab1a..865416b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -9,6 +9,13 @@ pub fn array_to_utf8(array: [u8; X]) -> Result String { + unsafe { + let (_, data, _) = array.align_to(); + String::from_utf16_lossy(&data).trim_matches(char::from(0)).into() + } +} + // TODO: const fn version of this! (helpful with tests) #[macro_export]