Function strip_prefix

Source
pub const fn strip_prefix<'a>(string: &'a str, prefix: &str) -> Option<&'a str>
Expand description

A const subset of str::strip_prefix, this only takes a &str pattern.

ยงExample

use konst::string;

{
    const STRIP: Option<&str> = string::strip_prefix("3 5 8", "3");
    assert_eq!(STRIP, Some(" 5 8"));
}
{
    const STRIP: Option<&str> = string::strip_prefix("3 5 8", "3 5 ");
    assert_eq!(STRIP, Some("8"));
}
{
    const STRIP: Option<&str> = string::strip_prefix("3 5 8", "hello");
    assert_eq!(STRIP, None);
}