windows-rs icon indicating copy to clipboard operation
windows-rs copied to clipboard

```windows-strings``` ```PCWSTR::as_wide``` return lifetime should be modifiable

Open NewYearPrism opened this issue 3 weeks ago • 2 comments

Summary

Below fails to compile:

let p_cmdline = unsafe { GetCommandLineW() };
OsString::from_wide(unsafe { windows_strings::PCWSTR::from_raw(p_cmdline).as_wide() });

It should have no problem since the validity of returned &[u16] does not depend on PCWSTR. Or is that on purpose out of consideration?

(Now workaround is to use core::slice::from_raw_parts by myself.

Crate manifest

windows-strings = "0.5.1"

Crate code


NewYearPrism avatar Dec 17 '25 17:12 NewYearPrism