fn highlight_char_literal(input: &str) -> Vec<Highlight> {
        let line = input.as_bytes();
        // character literal requires at least 3 characters
        if line[0] != b'\'' || line.len() < 3 {
            Vec::new()
        } else {
            let escaped = line[1] == b'\\' && line.len() > 3;
            let close_pos = if escaped { 3 } else { 2 };
            if line[close_pos] == b'\'' {
                vec![Highlight::Strings; close_pos + 1]
            } else {
                Vec::new()
            }
        }
    }
/// Parse a single quoted character 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 literal
///
/// # Examples
/// ```
/// assert_eq!(vec![Highlight::Strings; 3], highlight_string("'c' is a char"))
/// assert_eq!(Vec::new(), highlight_string("no chars"))
/// assert_eq!(vec![Highlight::Strings; 4], highlight_string("'\'' is a char"))
/// ```
Parse a single quoted character out of a line, returning Highlight codes for it.
Parse a single quoted character out of a line returning Highlight codes for it .
fn highlight_char_literal(input: &str) -> Vec<Highlight> {
        let line = input.as_bytes();
        // character literal requires at least 3 characters
        if line[0] != b'\'' || line.len() < 3 {
            Vec::new()
        } else {
            let escaped = line[1] == b'\\' && line.len() > 3;
            let close_pos = if escaped { 3 } else { 2 };
            if line[close_pos] == b'\'' {
                vec![Highlight::Strings; close_pos + 1]
            } else {
                Vec::new()
            }
        }
    }
fn highlight_char_literal ( input : & str ) -> Vec < Highlight > { let line = input . as_bytes ( ) ; // character literal requires at least 3 characters if line [ 0 ] != b'\'' || line . len ( ) < 3 { Vec :: new ( ) } else { let escaped = line [ 1 ] == b'\\' && line . len ( ) > 3 ; let close_pos = if escaped { 3 } else { 2 } ; if line [ close_pos ] == b'\'' { vec ! [ Highlight Strings close_pos 1 ] } else { Vec :: new ( ) } } }
Parse a single quoted character out of a line, returning Highlight codes for it.
Parse a single quoted character 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 literal
a ` Vec ` containing the code for the prefix of the line that is the literal
examples
```
assert_eq!(vec![Highlight::Strings; 3], highlight_string("'c' is a char"))
assert_eq!(Vec::new(), highlight_string("no chars"))
assert_eq!(vec![Highlight::Strings; 4], highlight_string("'\'' is a char"))
```
` ` ` assert_eq! ( vec! [ Highlight :: Strings ; 3 ] highlight_string ( " ' c ' is a char " )) assert_eq! ( Vec :: new () highlight_string ( " no chars " )) assert_eq! ( vec! [ Highlight :: Strings ; 4 ] highlight_string ( " ' \ ' ' is a char " )) ` ` `