Function parse_parentheses

Source
pub fn parse_parentheses<'a>(
    input: &'a str,
    stopwords: &[&'static str],
) -> Result<(&'static str, &'a str), ParenthesisParseError<'a>>
Expand description

Checks wheter a given input is enclosed in parentheses, prefixed by a certain number of stopwords.

On success, returns what the stopword was + the string inside the braces on failure returns None.

// Search for the nearest "abc()" brace
assert_eq!(parse_parentheses("abc(def(g))", &["abc"]), Ok(("abc", "def(g)")));
assert_eq!(parse_parentheses("abc(def(g))", &["def"]), Err(StopWordNotFound("abc")));
assert_eq!(parse_parentheses("def(ghi(j))", &["def"]), Ok(("def", "ghi(j)")));
assert_eq!(parse_parentheses("abc(def(g))", &["abc", "def"]), Ok(("abc", "def(g)")));