fn lex_string(l: &mut Lexer) -> Option<StateFn> {
    let mut text = String::new();
    while let Some(ch) = l.next() {
        match ch {
            // pass over escaped characters
            '\\' => {
                if let Some(ch) = l.next() {
                    match ch {
                        '"' => text.push('"'),
                        ' ' | '\t' => text.push(ch),
                        _ => {
                            // otherwise let replace_escapes() handle it
                            text.push('\\');
                            text.push(ch);
                        }
                    }
                } else {
                    return errorf(l, "improperly terminated string");
                }
            }
            '"' => {
                // reached the end of the string
                match replace_escapes(&text[..]) {
                    Ok(escaped) => {
                        l.emit_text(TokenType::String, &escaped[..]);
                        return Some(StateFn(lex_start));
                    }
                    Err(msg) => {
                        return errorf(l, msg);
                    }
                }
            }
            _ => {
                text.push(ch);
            }
        }
    }
    errorf(l, "unclosed quoted string")
}
/// `lex_string` expects the current character to be a double-quote and
/// scans the input to find the end of the quoted string.
`lex_string` expects the current character to be a double-quote and
scans the input to find the end of the quoted string.
` lex_string ` expects the current character to be a double - quote and scans the input to find the end of the quoted string .
fn lex_string(l: &mut Lexer) -> Option<StateFn> {
    let mut text = String::new();
    while let Some(ch) = l.next() {
        match ch {
            // pass over escaped characters
            '\\' => {
                if let Some(ch) = l.next() {
                    match ch {
                        '"' => text.push('"'),
                        ' ' | '\t' => text.push(ch),
                        _ => {
                            // otherwise let replace_escapes() handle it
                            text.push('\\');
                            text.push(ch);
                        }
                    }
                } else {
                    return errorf(l, "improperly terminated string");
                }
            }
            '"' => {
                // reached the end of the string
                match replace_escapes(&text[..]) {
                    Ok(escaped) => {
                        l.emit_text(TokenType::String, &escaped[..]);
                        return Some(StateFn(lex_start));
                    }
                    Err(msg) => {
                        return errorf(l, msg);
                    }
                }
            }
            _ => {
                text.push(ch);
            }
        }
    }
    errorf(l, "unclosed quoted string")
}
fn lex_string ( l : & mut Lexer ) -> Option < StateFn > { let mut text = String :: new ( ) ; while let Some ( ch ) = l . next ( ) { match ch { // pass over escaped characters '\\' => { if let Some ( ch ) = l . next ( ) { match ch { '"' => text . push ( '"' ) , ' ' | '\t' => text . push ( ch ) , _ => { // otherwise let replace_escapes() handle it text . push ( '\\' ) ; text . push ( ch ) ; } } } else { return errorf ( l , " " ) ; } } '"' => { // reached the end of the string match replace_escapes ( & text [ .. ] ) { Ok ( escaped ) => { l . emit_text ( TokenType :: String , & escaped [ .. ] ) ; return Some ( StateFn ( lex_start ) ) ; } Err ( msg ) => { return errorf ( l , msg ) ; } } } _ => { text . push ( ch ) ; } } } errorf ( l , " " ) }
`lex_string` expects the current character to be a double-quote and
scans the input to find the end of the quoted string.
` lex_string ` expects the current character to be a double - quote and scans the input to find the end of the quoted string .
l
&mut Lexer