Function quoted_phrases

Source
pub fn quoted_phrases<'a, W>(phrase: W) -> impl Iterator<Item = Substr<'a>>
where W: Into<Substr<'a>>,
Expand description

Iterate through the possible phrases in the input (always starting from the first word). In the event that the first word is quoted per quoted_words, the first result will be the contents of the quotes, but subsequent results will include the quotes as part of a larger phrase.

Also like quoted_words, the returned values are Substr objects, which can be cast back to &str using Substr::as_str.

ยงExamples

let mut iter = quoted_phrases(r#"  "Medium" Dave Lilywhite  "#)
    .map(|substr| substr.as_str());

assert_eq!(Some("Medium"), iter.next());
assert_eq!(Some(r#""Medium" Dave"#), iter.next());
assert_eq!(Some(r#""Medium" Dave Lilywhite"#), iter.next());
assert_eq!(None, iter.next());