Use an else if

This commit is contained in:
DJMcNab 2019-01-01 11:10:08 +00:00
parent 72ab6f7727
commit 0fd87cbc47

View file

@ -92,12 +92,11 @@ fn validate_ascii_code_escape(text: &str, range: TextRange, errors: &mut Vec<Syn
if !text.is_ascii() { if !text.is_ascii() {
// TODO: Give a more precise error message (say what the invalid character was) // TODO: Give a more precise error message (say what the invalid character was)
errors.push(SyntaxError::new(AsciiCodeEscapeOutOfRange, range)); errors.push(SyntaxError::new(AsciiCodeEscapeOutOfRange, range));
} } else if text.chars().count() < 4 {
if text.len() < 4 {
errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range)); errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range));
} else { } else {
assert_eq!( assert_eq!(
text.len(), text.chars().count(),
4, 4,
"AsciiCodeEscape cannot be longer than 4 chars, but text '{}' is", "AsciiCodeEscape cannot be longer than 4 chars, but text '{}' is",
text, text,