Remove second arg from parse functions again

Signed-off-by: trivernis <trivernis@protonmail.com>
master
trivernis 4 years ago
parent 8cb21fcaca
commit 4301930b1b
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,6 @@
[package] [package]
name = "charred" name = "charred"
version = "2.1.0" version = "2.1.1"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -22,7 +22,7 @@ impl Lexer {
let mut found = false; let mut found = false;
for checker_fn in &self.checkers { for checker_fn in &self.checkers {
if let Some(token) = checker_fn.as_ref()(&mut self.reader, tokens.last()).await? { if let Some(token) = checker_fn.as_ref()(&mut self.reader).await? {
tokens.push(token); tokens.push(token);
found = true; found = true;
break; break;

@ -52,9 +52,9 @@ async fn parse_string_token(reader: &mut InputReader) -> TapeResult<Option<Token
#[tokio::test] #[tokio::test]
async fn it_scans() { async fn it_scans() {
let checkers: Vec<TokenCheckerFn> = vec![ let checkers: Vec<TokenCheckerFn> = vec![
Arc::new(|reader, _| Box::pin(parse_number_token(reader))), Arc::new(|reader| Box::pin(parse_number_token(reader))),
Arc::new(|reader, _| Box::pin(parse_whitespace_token(reader))), Arc::new(|reader| Box::pin(parse_whitespace_token(reader))),
Arc::new(|reader, _| Box::pin(parse_string_token(reader))), Arc::new(|reader| Box::pin(parse_string_token(reader))),
]; ];
let input_reader = InputReader::new(Cursor::new("The Alphabet 12 ok")); let input_reader = InputReader::new(Cursor::new("The Alphabet 12 ok"));
let mut lexer = Lexer::new(input_reader, checkers); let mut lexer = Lexer::new(input_reader, checkers);
@ -75,8 +75,8 @@ async fn it_scans() {
#[tokio::test] #[tokio::test]
async fn it_falls_back_to_unknown() { async fn it_falls_back_to_unknown() {
let checkers: Vec<TokenCheckerFn> = vec![ let checkers: Vec<TokenCheckerFn> = vec![
Arc::new(|reader, _| Box::pin(parse_number_token(reader))), Arc::new(|reader| Box::pin(parse_number_token(reader))),
Arc::new(|reader, _| Box::pin(parse_string_token(reader))), Arc::new(|reader| Box::pin(parse_string_token(reader))),
]; ];
let input_reader = InputReader::new(Cursor::new("The Alphabet 12 ok")); let input_reader = InputReader::new(Cursor::new("The Alphabet 12 ok"));
let mut lexer = Lexer::new(input_reader, checkers); let mut lexer = Lexer::new(input_reader, checkers);

@ -8,7 +8,6 @@ use std::sync::Arc;
pub type TokenCheckerFn = Arc< pub type TokenCheckerFn = Arc<
dyn for<'a> Fn( dyn for<'a> Fn(
&'a mut InputReader, &'a mut InputReader,
Option<&'a Token>, // last token
) -> Pin<Box<dyn Future<Output = TapeResult<Option<Token>>> + Send + 'a>> ) -> Pin<Box<dyn Future<Output = TapeResult<Option<Token>>> + Send + 'a>>
+ Send + Send
+ Sync, + Sync,

Loading…
Cancel
Save