diff --git a/src/utils.rs b/src/utils.rs index c8c2a1d..d4171e0 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -32,12 +32,12 @@ pub(crate) fn from_bstr(string: BSTR) -> String { } pub(crate) fn from_lpstr(string: LPCSTR) -> String { - unsafe { - let len = (0..).take_while(|&i| *string.offset(i) != 0).count(); + let len = (0..) + .take_while(|&i| unsafe { *string.offset(i) } != 0) + .count(); - let slice: &[u8] = std::slice::from_raw_parts(string.cast(), len); - std::str::from_utf8(slice).map(|s| s.to_owned()).unwrap() - } + let slice: &[u8] = unsafe { std::slice::from_raw_parts(string.cast(), len) }; + std::str::from_utf8(slice).unwrap().to_owned() } struct DefaultIncludeHandler {}