use crate::{ToLowercase, ToUppercase};
pub trait EndsWithIgnoreCase {
fn ends_with_ignore_case<S: AsRef<str>>(&self, b: S) -> bool;
}
impl EndsWithIgnoreCase for str {
#[inline]
fn ends_with_ignore_case<S: AsRef<str>>(&self, b: S) -> bool {
let a = self;
let b = b.as_ref();
if b.is_empty() {
return true;
}
{
let au = a.to_uppercase_cow();
let bu = b.to_uppercase_cow();
if au.as_bytes().ends_with(bu.as_bytes()) {
return true;
}
}
let al = a.to_lowercase_cow();
let bl = b.to_lowercase_cow();
al.as_bytes().ends_with(bl.as_bytes())
}
}