(s: &str, u: *const u16)
| 7 | } |
| 8 | |
| 9 | fn compare_str_u16(s: &str, u: *const u16) -> bool { |
| 10 | unsafe { |
| 11 | let len = (0..).take_while(|&i| *u.offset(i) != 0).count(); |
| 12 | let slice = core::slice::from_raw_parts(u, len); |
| 13 | let s_len = s.len(); |
| 14 | if len != s_len { |
| 15 | return false; |
| 16 | } |
| 17 | let ss = s.as_bytes(); |
| 18 | for i in 0..len { |
| 19 | if slice[i] != ss[i] as u16 { |
| 20 | return false; |
| 21 | } |
| 22 | } |
| 23 | return true; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // TODO: use alloc |
| 28 | pub fn str_to_u16_ptr(s: &str, buf: &mut [u16]) { |
nothing calls this directly
no outgoing calls
no test coverage detected