https://github.com/discretetom/in_str
A procedural macro to generate a closure that checks if a character is in the provided literal string.
https://github.com/discretetom/in_str
rust
Last synced: 3 months ago
JSON representation
A procedural macro to generate a closure that checks if a character is in the provided literal string.
- Host: GitHub
- URL: https://github.com/discretetom/in_str
- Owner: DiscreteTom
- License: mit
- Created: 2024-11-20T12:36:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-02T03:48:00.000Z (11 months ago)
- Last Synced: 2025-10-14T12:49:59.019Z (3 months ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `in_str!`

[](https://crates.io/crates/in_str)
[](https://docs.rs/in_str/)
A procedural macro to generate a closure that checks if a character is in the provided literal string.
## Installation
```bash
cargo add in_str
```
## Usage
```rust
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}');
// also works with byte strings
let _ = in_str!(b"abc");
// equals to
let _ = |c: u8| matches!(c, b'a' | b'b' | b'c');
// escape will be handled automatically
let _ = in_str!(b"\n\xff");
// equals to
let _ = |c: u8| matches!(c, b'\n' | 0xff);
```
## [Documentation](https://docs.rs/in_str/)
## [CHANGELOG](./CHANGELOG.md)