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() {
// TODO: Give a more precise error message (say what the invalid character was)
errors.push(SyntaxError::new(AsciiCodeEscapeOutOfRange, range));
}
if text.len() < 4 {
} else if text.chars().count() < 4 {
errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range));
} else {
assert_eq!(
text.len(),
text.chars().count(),
4,
"AsciiCodeEscape cannot be longer than 4 chars, but text '{}' is",
text,