Skip to content

Feature request: Provide more const support for string types #2049

@seritools

Description

@seritools

Motivation

w! allows you to create a &'static HSTRING, but .as_ptr() and other conversions don't seem to be const, so it doesn't seem possible to get a const PCWSTR from it, in const context. Currently I'm using wchar::wchz! as alternative: PCWSTR::from_raw(wchz!("my string").as_ptr()). It would be nice to have a built-in way to do this.

Another tiny one is to create a const null-PCWSTR, but PCWSTR::null is not marked as const. PCWSTR(std::ptr::null()) is the slightly uglier workaround :)
The same should be the case for the other string types (PWSTR, and the 8bit string types). null(), as_ptr() and is_null() all can be marked as const fn as far as I can tell.

Drawbacks

No response

Rationale and alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions