Skip to content

Commit d141761

Browse files
committed
Directly unwrap
1 parent e26df2c commit d141761

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

parser/src/lexer.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ where
447447
}
448448
}
449449

450-
fn parse_octet(&mut self, first: char) -> Result<char, LexicalError> {
450+
fn parse_octet(&mut self, first: char) -> char {
451451
let mut octet_content = String::new();
452452
octet_content.push(first);
453453
while octet_content.len() < 3 {
@@ -457,13 +457,8 @@ where
457457
break;
458458
}
459459
}
460-
match u32::from_str_radix(&octet_content, 8) {
461-
Ok(result) => Ok(char::from_u32(result).unwrap()),
462-
Err(error) => Err(LexicalError {
463-
error: LexicalErrorType::OtherError(error.to_string()),
464-
location: self.get_pos(),
465-
}),
466-
}
460+
let value = u32::from_str_radix(&octet_content, 8).unwrap();
461+
char::from_u32(value).unwrap()
467462
}
468463

469464
fn parse_unicode_name(&mut self) -> Result<char, LexicalError> {
@@ -555,7 +550,7 @@ where
555550
string_content.push('\t');
556551
}
557552
Some('v') => string_content.push('\x0b'),
558-
Some(o @ '0'..='7') => string_content.push(self.parse_octet(o)?),
553+
Some(o @ '0'..='7') => string_content.push(self.parse_octet(o)),
559554
Some('x') => string_content.push(self.unicode_literal(2)?),
560555
Some('u') if !is_bytes => string_content.push(self.unicode_literal(4)?),
561556
Some('U') if !is_bytes => string_content.push(self.unicode_literal(8)?),

0 commit comments

Comments
 (0)