fn clean_non_meta_escapes(pattern: &str) -> String {
    if pattern.is_empty() {
        return pattern.to_string();
    }

    #[derive(Debug, Copy, Clone)]
    enum SlashState {
        No,
        Single,
        Double,
    }

    let mut next_state = SlashState::No;

    let next_chars = pattern
        .chars()
        .map(Some)
        .skip(1)
        .chain(std::iter::once(None));

    // emit char based on previous
    let new_pattern: String = pattern
        .chars()
        .zip(next_chars)
        .filter_map(|(c, next_char)| {
            let cur_state = next_state;
            next_state = match (c, cur_state) {
                ('\\', SlashState::No) => SlashState::Single,
                ('\\', SlashState::Single) => SlashState::Double,
                ('\\', SlashState::Double) => SlashState::Single,
                _ => SlashState::No,
            };

            // Decide to emit `c` or not
            match (cur_state, c, next_char) {
                (SlashState::No, '\\', Some(next_char))
                | (SlashState::Double, '\\', Some(next_char))
                    if !is_valid_character_after_escape(next_char) =>
                {
                    None
                }
                _ => Some(c),
            }
        })
        .collect();

    new_pattern
}
/// Removes all `/` patterns that the rust regex library would reject
/// and rewrites them to their unescaped form.
///
/// For example, `\:` is rewritten to `:` as `\:` is not a valid
/// escape sequence in the `regexp` crate but is valid in golang's
/// regexp implementation.
///
/// This is done for compatibility purposes so that the regular
/// expression matching in Rust more closely follows the matching in
/// golang, used by the influx storage rpc.
///
/// See <https://github.com/rust-lang/regex/issues/501> for more details
Removes all `/` patterns that the rust regex library would reject
and rewrites them to their unescaped form.



This is done for compatibility purposes so that the regular
expression matching in Rust more closely follows the matching in
golang, used by the influx storage rpc.

See  for more details
Removes all ` / ` patterns that the rust regex library would reject and rewrites them to their unescaped form . This is done for compatibility purposes so that the regular expression matching in Rust more closely follows the matching in golang used by the influx storage rpc . See for more details
fn clean_non_meta_escapes(pattern: &str) -> String {
    if pattern.is_empty() {
        return pattern.to_string();
    }
    #[derive(Debug, Copy, Clone)]
    enum SlashState {
        No,
        Single,
        Double,
    }
    let mut next_state = SlashState::No;
    let next_chars = pattern
        .chars()
        .map(Some)
        .skip(1)
        .chain(std::iter::once(None));
    // emit char based on previous
    let new_pattern: String = pattern
        .chars()
        .zip(next_chars)
        .filter_map(|(c, next_char)| {
            let cur_state = next_state;
            next_state = match (c, cur_state) {
                ('\\', SlashState::No) => SlashState::Single,
                ('\\', SlashState::Single) => SlashState::Double,
                ('\\', SlashState::Double) => SlashState::Single,
                _ => SlashState::No,
            };
            // Decide to emit `c` or not
            match (cur_state, c, next_char) {
                (SlashState::No, '\\', Some(next_char))
                | (SlashState::Double, '\\', Some(next_char))
                    if !is_valid_character_after_escape(next_char) =>
                {
                    None
                }
                _ => Some(c),
            }
        })
        .collect();
    new_pattern
}
fn clean_non_meta_escapes ( pattern : & str ) -> String { if pattern . is_empty ( ) { return pattern . to_string ( ) ; } # [ derive ( Debug Copy Clone ) ] enum SlashState { No , Single , Double , } let mut next_state = SlashState :: No ; let next_chars = pattern . chars ( ) . map ( Some ) . skip ( 1 ) . chain ( std :: iter :: once ( None ) ) ; // emit char based on previous let new_pattern : String = pattern . chars ( ) . zip ( next_chars ) . filter_map ( | ( c , next_char ) | { let cur_state = next_state ; next_state = match ( c , cur_state ) { ( '\\' , SlashState :: No ) => SlashState :: Single , ( '\\' , SlashState :: Single ) => SlashState :: Double , ( '\\' , SlashState :: Double ) => SlashState :: Single , _ => SlashState :: No , } ; // Decide to emit `c` or not match ( cur_state , c , next_char ) { ( SlashState :: No , '\\' , Some ( next_char ) ) | ( SlashState :: Double , '\\' , Some ( next_char ) ) if ! is_valid_character_after_escape ( next_char ) => { None } _ => Some ( c ) , } } ) . collect ( ) ; new_pattern }
Removes all `/` patterns that the rust regex library would reject
and rewrites them to their unescaped form.
Removes all ` / ` patterns that the rust regex library would reject and rewrites them to their unescaped form .
pattern
&str
pattern
&str