stable_string_patterns_method

Crates.iostable_string_patterns_method
lib.rsstable_string_patterns_method
version0.0.1
created_at2026-01-21 22:23:47.915671+00
updated_at2026-01-21 22:23:47.915671+00
descriptionStable polyfill to be able to depends on a trait that mimics `str::pattern::Pattern` on stable Rust.
homepage
repositoryhttps://github.com/krtab/stable_string_patterns_method
max_upload_size
id2060239
size43,201
Arthur Carcano (krtab)

documentation

README

Stable polyfill to be able to depends on a trait that mimics str::pattern::Pattern on stable Rust.

fn starts_and_ends_with(haystack: &str, p: impl IntoSearchable + Clone) -> bool {
    haystack.starts_with_(p.clone()) && haystack.ends_with_(p)
}

assert!(starts_and_ends_with("aa bb aa", "aa"));
assert!(starts_and_ends_with("aa bb aa", 'a'));
assert!(starts_and_ends_with("aa bb cc", ['a','c']));
assert!(starts_and_ends_with("\t bb  \n", WhiteSpace));
Commit count: 11

cargo fmt