Lokathor / utf16_lit

Lets you make utf16 literals in rust.
https://docs.rs/utf16_lit/
zlib License
10 stars 5 forks source link

Guarantee Utf16 output #7

Open Plecra opened 4 years ago

Plecra commented 4 years ago

It'd be handy to have a type that guaranteed the encoding like str does. There could be an optional dependency on something like widestring, or just a very simple wrapper type that users can write conversions for.

pub struct Utf16([u16]);
impl Utf16 {
    pub unsafe fn from_utf16_unchecked(utf16: &[u16]) -> &Self;
    pub fn as_wide(&self) -> &[u16];
}
Lokathor commented 4 years ago

I'm not sure if a proc-macro crate can export non-proc-macro items.

If it can, i'd accept some sort of PR for this being an optional thing.

Lokathor commented 4 years ago

oh but this would probably work in v2!