check-ends-macro

Crates.iocheck-ends-macro
lib.rscheck-ends-macro
version1.0.3
sourcesrc
created_at2021-10-01 12:01:40.054011
updated_at2021-10-03 16:42:33.533439
description A couple of macros to simulate match with starts and ends of a string.
homepage
repositoryhttps://github.com/DumbMahreeo/check-ends-macro
max_upload_size
id459103
size3,539
(DumbMahreeo)

documentation

README

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"
}
Commit count: 12

cargo fmt