windows_result/
strings.rs1use super::*;
2
3pub struct HeapString(pub *mut u16);
4
5impl Default for HeapString {
6 fn default() -> Self {
7 Self(core::ptr::null_mut())
8 }
9}
10
11impl Drop for HeapString {
12 fn drop(&mut self) {
13 if !self.0.is_null() {
14 unsafe {
15 HeapFree(GetProcessHeap(), 0, self.0 as _);
16 }
17 }
18 }
19}
20
21pub fn wide_trim_end(mut wide: &[u16]) -> &[u16] {
22 while let Some(last) = wide.last() {
23 match last {
24 32 | 9..=13 => wide = &wide[..wide.len() - 1],
25 _ => break,
26 }
27 }
28 wide
29}