refactor(specctra-core/read): inline expect_leaf into only callsite

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-06 16:38:18 +01:00 committed by mikolaj
parent ca012a8c13
commit 7737aaf0cc
1 changed files with 6 additions and 9 deletions

View File

@ -21,14 +21,6 @@ impl InputToken {
} }
} }
pub fn expect_leaf(self) -> Result<String, ParseErrorContext> {
if let ListToken::Leaf { value } = self.token {
Ok(value)
} else {
Err(ParseError::ExpectedLeaf.add_context(self.context))
}
}
pub fn expect_end(self) -> Result<(), ParseErrorContext> { pub fn expect_end(self) -> Result<(), ParseErrorContext> {
if let ListToken::End = self.token { if let ListToken::End = self.token {
Ok(()) Ok(())
@ -59,7 +51,12 @@ impl<R: std::io::BufRead> ReadDsn<R> for Parser {
impl<R: std::io::BufRead> ReadDsn<R> for String { impl<R: std::io::BufRead> ReadDsn<R> for String {
fn read_dsn(tokenizer: &mut ListTokenizer<R>) -> Result<Self, ParseErrorContext> { fn read_dsn(tokenizer: &mut ListTokenizer<R>) -> Result<Self, ParseErrorContext> {
tokenizer.consume_token()?.expect_leaf() let inptoken = tokenizer.consume_token()?;
if let ListToken::Leaf { value } = inptoken.token {
Ok(value)
} else {
Err(ParseError::ExpectedLeaf.add_context(inptoken.context))
}
} }
} }