real_c_wstring!() { /* proc-macro */ }
Expand description

Same as real_c_string, but used for wchar_t* strings

The result of this macro invocation is of type *const i16.

use real_c_string::real_c_wstring;
assert_eq!(0i16, unsafe { *real_c_wstring!("") });

let c_wstring = real_c_wstring!("Hello world!");
let same_as_array_of_bytes: [i16; 13] =
    [72i16, 101i16, 108i16, 108i16, 111i16, 32i16, 119i16, 111i16, 114i16, 108i16, 100i16, 33i16, 0i16];
for i in 0..13 {
    assert_eq!(
        same_as_array_of_bytes[i],
        unsafe { *c_wstring.offset(i as isize) },
    );
}

let c_wstring = real_c_wstring!("Привет world!");
let same_as_array_of_bytes: [i16; 14]
    = [1055i16, 1088i16, 1080i16, 1074i16, 1077i16, 1090i16, 32i16, 119i16, 111i16, 114i16, 108i16, 100i16, 33i16, 0i16];
for i in 0..13 {
    assert_eq!(
        same_as_array_of_bytes[i],
        unsafe { *c_wstring.offset(i as isize) },
    );
}