macro_rules! strip_prefix {
($s: expr, $prefix: expr) => { ... };
}
Expand description
Returns a string slice with the prefix removed.
This macro is const-fn compatible.
ยงExamples
assert_eq!(const_str::strip_prefix!("foo:bar", "foo:"), Some("bar"));
assert_eq!(const_str::strip_prefix!("foo:bar", "bar"), None);
assert_eq!(const_str::strip_prefix!("foofoo", "foo"), Some("foo"));
const FOO_BAR: &str = "foo:bar";
const BAR: &str = const_str::unwrap!(const_str::strip_prefix!(FOO_BAR, "foo:"));
assert_eq!(BAR, "bar");