Skip to content

windows-strings PCWSTR::as_wide return lifetime should be modifiable #3836

@NewYearPrism

Description

@NewYearPrism

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions