Skip to content

Constants involving dereferencing in pattern matching #25574

Closed
@IvanUkhov

Description

@IvanUkhov

Constants that dereference string literals cannot be currently used for pattern matching as show below:

const A: [u8; 4] = *b"fooo";

fn main() {
    match *b"xxxx" {
        A => {},
        _ => {}
    }
}

Such constants can be used in other contexts without any problem. It is inconsistent, and a very prominent use case is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions