fn highlight_string(input: &str) -> Vec<Highlight> {
        let line = input.as_bytes();
        let mut h = Vec::new();
        if line.len() < 2 || line[0] != b'\"' {
            return h;
        }
        h.push(Highlight::Strings);
        let mut i = 1;

        // if we encounter \, skip next character (don't check for closing quote)
        let mut escaped = false;
        while i < line.len() {
            h.push(Highlight::Strings);
            match (escaped, line[i]) {
                (false, b'\"') => return h,
                (false, b'\\') => escaped = true,
                (true, _) => escaped = false,
                _ => (),
            }
            i += 1;
        }
        h
    }
/// Parse a quoted string out of a line, returning Highlight codes for it.
///
/// # Return value
/// a `Vec<Highlight>` containing the code for the prefix of the line that is the string
///
/// # Examples
/// ```
/// assert_eq!(vec![Highlight::Strings; 5], highlight_string("\"hi,\" she said"))
/// assert_eq!(Vec::new(), highlight_string("no quotes"))
/// assert_eq!(Vec::new(), highlight_string("'single quotes are not matched'"))
/// ```
Parse a quoted string out of a line, returning Highlight codes for it.
Parse a quoted string out of a line returning Highlight codes for it .
fn highlight_string(input: &str) -> Vec<Highlight> {
        let line = input.as_bytes();
        let mut h = Vec::new();
        if line.len() < 2 || line[0] != b'\"' {
            return h;
        }
        h.push(Highlight::Strings);
        let mut i = 1;
        // if we encounter \, skip next character (don't check for closing quote)
        let mut escaped = false;
        while i < line.len() {
            h.push(Highlight::Strings);
            match (escaped, line[i]) {
                (false, b'\"') => return h,
                (false, b'\\') => escaped = true,
                (true, _) => escaped = false,
                _ => (),
            }
            i += 1;
        }
        h
    }
fn highlight_string ( input : & str ) -> Vec < Highlight > { let line = input . as_bytes ( ) ; let mut h = Vec :: new ( ) ; if line . len ( ) < 2 || line [ 0 ] != b'\"' { return h ; } h . push ( Highlight :: Strings ) ; let mut i = 1 ; // if we encounter \, skip next character (don't check for closing quote) let mut escaped = false ; while i < line . len ( ) { h . push ( Highlight :: Strings ) ; match ( escaped , line [ i ] ) { ( false , b'\"' ) => return h , ( false , b'\\' ) => escaped = true , ( true , _ ) => escaped = false , _ => ( ) , } i += 1 ; } h }
Parse a quoted string out of a line, returning Highlight codes for it.
Parse a quoted string out of a line returning Highlight codes for it .
input
&str
return value
a `Vec` containing the code for the prefix of the line that is the string
a ` Vec ` containing the code for the prefix of the line that is the string
examples
```
assert_eq!(vec![Highlight::Strings; 5], highlight_string("\"hi,\" she said"))
assert_eq!(Vec::new(), highlight_string("no quotes"))
assert_eq!(Vec::new(), highlight_string("'single quotes are not matched'"))
```
` ` ` assert_eq! ( vec! [ Highlight :: Strings ; 5 ] highlight_string ( " \ " hi \ " she said " )) assert_eq! ( Vec :: new () highlight_string ( " no quotes " )) assert_eq! ( Vec :: new () highlight_string ( " ' single quotes are not matched ' " )) ` ` `