Macro strip_suffix
macro_rules! strip_suffix {
($s: expr, $suffix: expr) => { ... };
}
Available on crate feature
dep_const_str
only.Expand description
Returns a string slice with the suffix removed.
ยงExamples
assert_eq!(const_str::strip_suffix!("bar:foo", ":foo"), Some("bar"));
assert_eq!(const_str::strip_suffix!("bar:foo", "bar"), None);
assert_eq!(const_str::strip_suffix!("foofoo", "foo"), Some("foo"));
const FOO_BAR: &str = "foo:bar";
const FOO: &str = const_str::unwrap!(const_str::strip_suffix!(FOO_BAR, ":bar"));
assert_eq!(FOO, "foo");