pub trait StrExt {
fn x_contains(&self, text: &str) -> bool;
}
impl StrExt for String {
fn x_contains(&self, text: &str) -> bool {
self.contains(text)
}
}
impl StrExt for &str {
fn x_contains(&self, text: &str) -> bool {
self.contains(text)
}
}
impl StrExt for &String {
fn x_contains(&self, text: &str) -> bool {
self.contains(text)
}
}
impl<T: StrExt> StrExt for Option<T> {
fn x_contains(&self, text: &str) -> bool {
match self {
Some(s) => s.x_contains(text),
None => false,
}
}
}
impl<T: StrExt> StrExt for Vec<T> {
fn x_contains(&self, text: &str) -> bool {
self.iter().any(|s| s.x_contains(text))
}
}