pub const fn strip_suffix<'a>(string: &'a str, suffix: &str) -> Option<&'a str>
Expand description
A const subset of str::strip_suffix
, this only takes a &str
pattern.
ยงExample
use konst::string;
{
const STRIP: Option<&str> = string::strip_suffix("3 5 8", "8");
assert_eq!(STRIP, Some("3 5 "));
}
{
const STRIP: Option<&str> = string::strip_suffix("3 5 8", " 5 8");
assert_eq!(STRIP, Some("3"));
}
{
const STRIP: Option<&str> = string::strip_suffix("3 5 8", "hello");
assert_eq!(STRIP, None);
}