Skip to content

Recommendation for pattern matching #22

@sffc

Description

@sffc

On Rust Nightly, I got the following pattern match to work:

const FOO: TinyStr16 = tinystr16!("foo");
const BAR: TinyStr16 = tinystr16!("bar");
match tinystr_input {
    FOO => /* ... */,
    BAR => /* ... */,
    _ => /* ... */,
}

This is fine, but it would be nicer if I could write

match tinystr_input {
    tinystr16!("foo") => /* ... */,
    tinystr16!("bar") => /* ... */,
    _ => /* ... */,
}

Unfortunately, this doesn't seem to work right now.

Is the first example the best way to do pattern matching on TinyStr, or is there a better way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions