maybe-regex
Regex is amazing, but it's also slower than a plain-text search. This is a simple utility that wraps some generic needle, attempts to detect if it looks regex-y, and then provides some useful functions for using it.
Usage
// Regexes work as you'd expect
assert_eq!;
// As do plain strings
assert_eq!;
// Plain string search is case insensitive by default
assert_eq!;
// ...though that can be disabled
assert_eq!;
// Strings that start or end with a '-' are understood to be "negative".
// So haystacks that contain the string won't match and vice-versa.
assert_eq!;
// You can ignore "negative" behavior by using the 'is_contained_within' method.
assert_eq!;
Performance
It's about what you'd expect, roughly as fast as a regex for regexes or plain strings for plain strings.
The most expensive feature, case insensitivity by default, can be disabled if you'd like:
let needle = new.as_case_sensitive;