const_format_proc_macros 0.2.29

Implementation detail of the `const_format` crate
Documentation
pub trait StrExt {
    fn as_str(&self) -> &str;

    /// Checks that these needles exist consequtively in self.
    ///
    /// Example: `"hello world".consecutive_in_set(&["he", "wor"])` returns `true`.
    /// Example: `"hello world".consecutive_in_set(&["wor", "he"])` returns `false`.
    fn consecutive_in_self(&self, needles: &[&str]) -> bool {
        let mut rem = self.as_str();
        for needle in needles {
            rem = match rem.find(needle) {
                Some(next) => &rem[next + needle.len()..],
                None => return false,
            };
        }
        true
    }
}

impl StrExt for str {
    #[inline(always)]
    fn as_str(&self) -> &str {
        self
    }
}

impl StrExt for String {
    #[inline(always)]
    fn as_str(&self) -> &str {
        self
    }
}