Crates.io | in_str |
lib.rs | in_str |
version | 0.1.0 |
source | src |
created_at | 2024-11-20 12:49:28.923757 |
updated_at | 2024-11-20 12:49:28.923757 |
description | A procedural macro to generate a closure that checks if a character is in the provided literal string. |
homepage | |
repository | https://github.com/DiscreteTom/in_str |
max_upload_size | |
id | 1454765 |
size | 5,231 |
in_str!
use in_str::in_str;
let _ = in_str!("abc");
// equals to
let _ = |c: char| matches!(c, 'a' | 'b' | 'c');
// usually faster than
let _ = |c: char| "abc".contains(c);
// escape will be handled automatically
let _ = in_str!("\n\u{10ffff}");
// equals to
let _ = |c: char| matches!(c, '\n' | '\u{10ffff}');