#ends #match #string #starts #macro #simulation #couple

check-ends-macro

A couple of macros to simulate match with starts and ends of a string

1 stable release

1.0.3 Oct 3, 2021
1.0.2 Oct 1, 2021

#2217 in Rust patterns

MIT license

3KB

Use

It's like a match, but it returns an Option

let to_match = "hello world";

let opt = match_start! {to_match,
    "hello" | "something" => "something else"
    "world" | "another" => "another thing"
};

if let Some(value) = opt {
    println!("{}", value); // Will print "something else"
}

No runtime deps