From 9cf5260d4bd4e1d3b69d64aacd5e10510d25e582 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 11 May 2018 02:08:05 -0700 Subject: [PATCH] Use impl Trait to simplify type signatures --- schala-lang/src/tokenizing.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/schala-lang/src/tokenizing.rs b/schala-lang/src/tokenizing.rs index 0c6aad1..52687e0 100644 --- a/schala-lang/src/tokenizing.rs +++ b/schala-lang/src/tokenizing.rs @@ -105,7 +105,7 @@ fn is_operator(c: &char) -> bool { OPERATOR_CHARS.iter().any(|x| x == c) } -type CharIter> = Peekable; +type CharData = (usize, usize, char); pub fn tokenize(input: &str) -> Vec { let mut tokens: Vec = Vec::new(); @@ -164,7 +164,7 @@ pub fn tokenize(input: &str) -> Vec { tokens } -fn handle_digit>(c: char, input: &mut CharIter) -> TokenType { +fn handle_digit(c: char, input: &mut Peekable>) -> TokenType { if c == '0' && input.peek().map_or(false, |&(_, _, c)| { c == 'x' }) { input.next(); let rest: String = input.peeking_take_while(|&(_, _, ref c)| c.is_digit(16) || *c == '_').map(|(_, _, c)| { c }).collect(); @@ -179,7 +179,7 @@ fn handle_digit>(c: char, input: &mut CharI } } -fn handle_quote>(input: &mut CharIter) -> TokenType { +fn handle_quote(input: &mut Peekable>) -> TokenType { let mut buf = String::new(); loop { match input.next().map(|(_, _, c)| { c }) { @@ -204,7 +204,7 @@ fn handle_quote>(input: &mut CharIter) - TokenType::StrLiteral(Rc::new(buf)) } -fn handle_alphabetic>(c: char, input: &mut CharIter) -> TokenType { +fn handle_alphabetic(c: char, input: &mut Peekable>) -> TokenType { let mut buf = String::new(); buf.push(c); if c == '_' && input.peek().map(|&(_, _, c)| { !c.is_alphabetic() }).unwrap_or(true) { @@ -227,7 +227,7 @@ fn handle_alphabetic>(c: char, input: &mut } } -fn handle_operator>(c: char, input: &mut CharIter) -> TokenType { +fn handle_operator(c: char, input: &mut Peekable>) -> TokenType { match c { '<' | '>' | '|' | '.' => { let ref next = input.peek().map(|&(_, _, c)| { c });