Crate jetscii [] [src]

A tiny library to efficiently search strings for substrings or sets of ASCII characters.

Examples

Searching for a set of ASCII characters

use jetscii::AsciiChars;
let mut search = AsciiChars::new();
search.push(b'-');
search.push(b':');
let part_number = "86-J52:rev1";
let parts: Vec<_> = part_number.split(search.with_fallback(|c| {
    c == b'-' || c == b':'
})).collect();
assert_eq!(&parts, &["86", "J52", "rev1"]);

For maximum performance, you can create the searcher as a constant item. Print an existing AsciiChars with the debug formatter to get the appropriate invocation.

use jetscii::AsciiChars;
let search = AsciiChars::from_words(0x0000000000002d3a, 0, 2);
let part_number = "86-J52:rev1";
let parts: Vec<_> = part_number.split(search.with_fallback(|c| {
    c == b'-' || c == b':'
})).collect();
assert_eq!(&parts, &["86", "J52", "rev1"]);

Searching for a substring

use jetscii::Substring;
let colors: Vec<_> = "red, blue, green".split(Substring::new(", ")).collect();
assert_eq!(&colors, &["red", "blue", "green"]);

Structs

AsciiChars

Searches a string for a set of ASCII characters. Up to 16 characters may be used.

AsciiCharsWithFallback

Provides a hook for a user-supplied fallback implementation, used when the optimized instructions are not available.

DirectSearcher

A searcher implementation for DirectSearch types.

Substring

Search a string for a substring.

Traits

DirectSearch

Types that return the index of the next match.