diff --git a/src/args.rs b/src/args.rs index 385dbaa..7e1fa83 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,8 +1,9 @@ use std::collections::HashMap; -use std::iter::Peekable; use codemap::{Span, Spanned}; +use peekmore::PeekMoreIterator; + use crate::error::SassResult; use crate::scope::Scope; use crate::selector::Selector; @@ -172,7 +173,7 @@ impl CallArgs { } pub(crate) fn eat_func_args>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { @@ -275,7 +276,7 @@ pub(crate) fn eat_func_args>( } pub(crate) fn eat_call_args>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { diff --git a/src/atrule/for_rule.rs b/src/atrule/for_rule.rs index d2077d9..0a11b2b 100644 --- a/src/atrule/for_rule.rs +++ b/src/atrule/for_rule.rs @@ -1,7 +1,7 @@ -use std::iter::Peekable; - use codemap::{Span, Spanned}; +use peekmore::{PeekMore, PeekMoreIterator}; + use num_traits::cast::ToPrimitive; use super::parse::eat_stmts; @@ -18,7 +18,7 @@ use crate::value::{Number, Value}; use crate::Token; pub(crate) fn parse_for>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &mut Scope, super_selector: &Selector, span: Span, @@ -155,7 +155,7 @@ pub(crate) fn parse_for>( }, )?; stmts.extend(eat_stmts( - &mut body.clone().into_iter().peekable(), + &mut body.clone().into_iter().peekmore(), scope, super_selector, )?); diff --git a/src/atrule/function.rs b/src/atrule/function.rs index d495f32..3eca18d 100644 --- a/src/atrule/function.rs +++ b/src/atrule/function.rs @@ -1,9 +1,9 @@ -use std::iter::Peekable; - use super::eat_stmts; use codemap::{Span, Spanned}; +use peekmore::{PeekMore, PeekMoreIterator}; + use crate::args::{eat_func_args, CallArgs, FuncArgs}; use crate::atrule::AtRule; use crate::error::SassResult; @@ -40,7 +40,7 @@ impl Function { } pub fn decl_from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: Scope, super_selector: &Selector, ) -> SassResult<(String, Function)> { @@ -84,7 +84,7 @@ impl Function { Some(v) => v?, None => match &arg.default { Some(v) => Value::from_tokens( - &mut v.iter().cloned().peekable(), + &mut v.iter().cloned().peekmore(), scope, super_selector, )?, @@ -110,7 +110,7 @@ impl Function { match stmt.node { Stmt::AtRule(AtRule::Return(toks)) => { return Ok(Value::from_tokens( - &mut toks.into_iter().peekable(), + &mut toks.into_iter().peekmore(), &self.scope, super_selector, )? diff --git a/src/atrule/if_rule.rs b/src/atrule/if_rule.rs index 05d94ca..4bf4be7 100644 --- a/src/atrule/if_rule.rs +++ b/src/atrule/if_rule.rs @@ -1,7 +1,7 @@ -use std::iter::Peekable; - use codemap::Spanned; +use peekmore::{PeekMore, PeekMoreIterator}; + use super::{eat_stmts, AtRule}; use crate::error::SassResult; @@ -32,7 +32,9 @@ impl Branch { } impl If { - pub fn from_tokens>(toks: &mut Peekable) -> SassResult { + pub fn from_tokens>( + toks: &mut PeekMoreIterator, + ) -> SassResult { let mut branches = Vec::new(); let init_cond = read_until_open_curly_brace(toks); toks.next(); @@ -111,7 +113,7 @@ impl If { if !found_true { toks = self.else_; } - for stmt in eat_stmts(&mut toks.into_iter().peekable(), scope, super_selector)? { + for stmt in eat_stmts(&mut toks.into_iter().peekmore(), scope, super_selector)? { match stmt.node { Stmt::AtRule(AtRule::If(i)) => stmts.extend(i.eval(scope, super_selector)?), Stmt::RuleSet(r) if r.selector.is_empty() => stmts.extend(r.rules), diff --git a/src/atrule/mixin.rs b/src/atrule/mixin.rs index 502d646..b018270 100644 --- a/src/atrule/mixin.rs +++ b/src/atrule/mixin.rs @@ -1,8 +1,9 @@ -use std::iter::Peekable; use std::vec::IntoIter; use codemap::Spanned; +use peekmore::{PeekMore, PeekMoreIterator}; + use super::eat_stmts; use crate::args::{eat_call_args, eat_func_args, CallArgs, FuncArgs}; @@ -20,7 +21,7 @@ use crate::{eat_expr, Expr, RuleSet, Stmt, Token}; pub(crate) struct Mixin { scope: Scope, args: FuncArgs, - body: Peekable>, + body: PeekMoreIterator>, content: Vec>, } @@ -31,7 +32,7 @@ impl Mixin { body: Vec, content: Vec>, ) -> Self { - let body = body.into_iter().peekable(); + let body = body.into_iter().peekmore(); Mixin { scope, args, @@ -41,7 +42,7 @@ impl Mixin { } pub fn decl_from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult> { @@ -95,7 +96,7 @@ impl Mixin { Some(v) => v?, None => match &arg.default { Some(v) => Value::from_tokens( - &mut v.iter().cloned().peekable(), + &mut v.iter().cloned().peekmore(), scope, super_selector, )?, @@ -177,7 +178,7 @@ impl Mixin { } pub(crate) fn eat_include>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult>> { diff --git a/src/atrule/mod.rs b/src/atrule/mod.rs index 29d9be2..eb20b8e 100644 --- a/src/atrule/mod.rs +++ b/src/atrule/mod.rs @@ -1,7 +1,7 @@ -use std::iter::Peekable; - use codemap::{Span, Spanned}; +use peekmore::{PeekMore, PeekMoreIterator}; + use crate::common::{Brackets, ListSeparator}; use crate::error::SassResult; use crate::scope::Scope; @@ -50,7 +50,7 @@ impl AtRule { pub fn from_tokens>( rule: &AtRuleKind, kind_span: Span, - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &mut Scope, super_selector: &Selector, ) -> SassResult> { @@ -139,7 +139,7 @@ impl AtRule { let mut selector = &Selector::replace( super_selector, Selector::from_tokens( - &mut read_until_open_curly_brace(toks).into_iter().peekable(), + &mut read_until_open_curly_brace(toks).into_iter().peekmore(), scope, super_selector, )?, @@ -156,7 +156,7 @@ impl AtRule { devour_whitespace(toks); let mut styles = Vec::new(); let raw_stmts = eat_stmts_at_root( - &mut body.into_iter().peekable(), + &mut body.into_iter().peekmore(), scope, selector, 0, @@ -284,7 +284,7 @@ impl AtRule { } stmts.extend(eat_stmts( - &mut body.clone().into_iter().peekable(), + &mut body.clone().into_iter().peekmore(), scope, super_selector, )?); @@ -323,7 +323,7 @@ impl AtRule { let mut val = Value::from_vec(cond.clone(), scope, super_selector)?; while val.node.is_true(val.span)? { stmts.extend(eat_stmts( - &mut body.clone().into_iter().peekable(), + &mut body.clone().into_iter().peekmore(), scope, super_selector, )?); diff --git a/src/atrule/parse.rs b/src/atrule/parse.rs index b1c9899..254c376 100644 --- a/src/atrule/parse.rs +++ b/src/atrule/parse.rs @@ -1,14 +1,14 @@ -use std::iter::Peekable; - use codemap::Spanned; +use peekmore::PeekMoreIterator; + use crate::error::SassResult; use crate::scope::Scope; use crate::selector::Selector; use crate::{eat_expr, Expr, RuleSet, Stmt, Token}; pub(crate) fn eat_stmts>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &mut Scope, super_selector: &Selector, ) -> SassResult>> { @@ -46,7 +46,7 @@ pub(crate) fn eat_stmts>( } pub(crate) fn eat_stmts_at_root>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &mut Scope, super_selector: &Selector, mut nesting: usize, diff --git a/src/atrule/unknown.rs b/src/atrule/unknown.rs index bfd0079..1d1964d 100644 --- a/src/atrule/unknown.rs +++ b/src/atrule/unknown.rs @@ -1,7 +1,7 @@ -use std::iter::Peekable; - use codemap::{Span, Spanned}; +use peekmore::PeekMoreIterator; + use super::parse::eat_stmts; use crate::error::SassResult; use crate::scope::Scope; @@ -19,7 +19,7 @@ pub(crate) struct UnknownAtRule { impl UnknownAtRule { pub fn from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, name: &str, scope: &mut Scope, super_selector: &Selector, diff --git a/src/lib.rs b/src/lib.rs index 8093905..342e32c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,11 +83,13 @@ grass input.scss use std::fmt::{self, Display}; use std::fs; use std::io::Write; -use std::iter::{Iterator, Peekable}; +use std::iter::Iterator; use std::path::Path; use codemap::{CodeMap, Span, Spanned}; +use peekmore::{PeekMore, PeekMoreIterator}; + use crate::atrule::{eat_include, AtRule, AtRuleKind, Function, Mixin}; pub use crate::error::{SassError, SassResult}; use crate::format::PrettyPrinter; @@ -220,7 +222,7 @@ impl StyleSheet { let file = map.add_file("stdin".into(), input); Css::from_stylesheet(StyleSheet( StyleSheetParser { - lexer: Lexer::new(&file).peekable(), + lexer: Lexer::new(&file).peekmore(), nesting: 0, map: &map, } @@ -255,7 +257,7 @@ impl StyleSheet { let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.as_ref())?)?); Css::from_stylesheet(StyleSheet( StyleSheetParser { - lexer: Lexer::new(&file).peekable(), + lexer: Lexer::new(&file).peekmore(), nesting: 0, map: &map, } @@ -275,7 +277,7 @@ impl StyleSheet { let mut map = CodeMap::new(); let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.as_ref())?)?); Ok(StyleSheetParser { - lexer: Lexer::new(&file).peekable(), + lexer: Lexer::new(&file).peekmore(), nesting: 0, map: &map, } @@ -288,7 +290,7 @@ impl StyleSheet { } struct StyleSheetParser<'a> { - lexer: Peekable>, + lexer: PeekMoreIterator>, nesting: u32, map: &'a CodeMap, } @@ -520,7 +522,7 @@ impl<'a> StyleSheetParser<'a> { } pub(crate) fn eat_expr>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &mut Scope, super_selector: &Selector, ) -> SassResult>> { @@ -537,7 +539,7 @@ pub(crate) fn eat_expr>( let tok = toks.next(); if devour_whitespace(toks) { let prop = Style::parse_property( - &mut values.into_iter().peekable(), + &mut values.into_iter().peekmore(), scope, super_selector, String::new(), @@ -555,7 +557,7 @@ pub(crate) fn eat_expr>( devour_whitespace(toks); // special edge case where there was no space between the colon // in a style, e.g. `color:red`. todo: refactor - let mut v = values.into_iter().peekable(); + let mut v = values.into_iter().peekmore(); devour_whitespace(&mut v); if v.peek().is_none() { devour_whitespace(toks); @@ -587,7 +589,7 @@ pub(crate) fn eat_expr>( // special edge case where there was no space between the colon // and no semicolon following the style // in a style `color:red`. todo: refactor - let mut v = values.into_iter().peekable(); + let mut v = values.into_iter().peekmore(); let property = Style::parse_property(&mut v, scope, super_selector, String::new())?; let value = Style::parse_value(&mut v, scope, super_selector)?; @@ -602,7 +604,7 @@ pub(crate) fn eat_expr>( devour_whitespace(toks); return Ok(Some(Spanned { node: Expr::Selector(Selector::from_tokens( - &mut values.into_iter().peekable(), + &mut values.into_iter().peekmore(), scope, super_selector, )?), @@ -713,7 +715,7 @@ pub(crate) fn eat_expr>( Ok(None) } -fn eat_interpolation>(toks: &mut Peekable) -> Vec { +fn eat_interpolation>(toks: &mut PeekMoreIterator) -> Vec { let mut vals = Vec::new(); let mut n = 1; for tok in toks { diff --git a/src/selector/attribute.rs b/src/selector/attribute.rs index e839256..5bdf542 100644 --- a/src/selector/attribute.rs +++ b/src/selector/attribute.rs @@ -1,5 +1,6 @@ use std::fmt::{self, Display}; -use std::iter::Peekable; + +use peekmore::PeekMoreIterator; use codemap::Span; @@ -21,7 +22,7 @@ pub(crate) struct Attribute { impl Attribute { pub fn from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, mut start: Span, diff --git a/src/selector/mod.rs b/src/selector/mod.rs index 52015df..4167064 100644 --- a/src/selector/mod.rs +++ b/src/selector/mod.rs @@ -1,5 +1,6 @@ use std::fmt::{self, Display, Write}; -use std::iter::Peekable; + +use peekmore::{PeekMore, PeekMoreIterator}; use crate::error::SassResult; use crate::scope::Scope; @@ -26,7 +27,7 @@ struct SelectorPart { impl Display for SelectorPart { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut iter = self.inner.iter().peekable(); + let mut iter = self.inner.iter().peekmore(); devour_whitespace(&mut iter); while let Some(s) = iter.next() { write!(f, "{}", s)?; @@ -176,7 +177,7 @@ fn is_selector_name_char(c: char) -> bool { impl Selector { pub fn from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { @@ -252,7 +253,7 @@ impl Selector { tok })); - let mut iter = sel_toks.into_iter().peekable(); + let mut iter = sel_toks.into_iter().peekmore(); while let Some(tok) = iter.peek() { inner.push(match tok.kind { @@ -360,7 +361,7 @@ impl Selector { } fn consume_pseudo_selector>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { @@ -378,7 +379,7 @@ impl Selector { let mut inner_toks = read_until_closing_paren(toks); inner_toks.pop(); let inner = Selector::from_tokens( - &mut inner_toks.into_iter().peekable(), + &mut inner_toks.into_iter().peekmore(), scope, super_selector, )?; diff --git a/src/style.rs b/src/style.rs index 21fff78..6b1e53b 100644 --- a/src/style.rs +++ b/src/style.rs @@ -1,4 +1,4 @@ -use std::iter::Peekable; +use peekmore::PeekMoreIterator; use codemap::Spanned; @@ -21,7 +21,7 @@ pub(crate) struct Style { impl Style { pub fn parse_property>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, super_property: String, @@ -48,7 +48,7 @@ impl Style { } pub fn parse_value>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult> { @@ -56,7 +56,7 @@ impl Style { } pub fn from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, super_property: String, @@ -80,7 +80,7 @@ impl<'a> StyleParser<'a> { pub(crate) fn parse_style_value>( &self, - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, ) -> SassResult> { devour_whitespace(toks); @@ -93,7 +93,7 @@ impl<'a> StyleParser<'a> { pub(crate) fn eat_style_group>( &self, - toks: &mut Peekable, + toks: &mut PeekMoreIterator, super_property: String, scope: &Scope, ) -> SassResult { @@ -199,7 +199,7 @@ impl<'a> StyleParser<'a> { pub(crate) fn parse_property>( &self, - toks: &mut Peekable, + toks: &mut PeekMoreIterator, mut super_property: String, ) -> SassResult { devour_whitespace(toks); diff --git a/src/utils.rs b/src/utils.rs index e8ff368..6a19525 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,9 @@ -use std::iter::{Iterator, Peekable}; +use std::iter::Iterator; use codemap::{Span, Spanned}; +use peekmore::{PeekMore, PeekMoreIterator}; + use crate::common::QuoteKind; use crate::error::SassResult; use crate::selector::Selector; @@ -19,7 +21,7 @@ impl IsWhitespace for char { } pub(crate) fn devour_whitespace, W: IsWhitespace>( - s: &mut Peekable, + s: &mut PeekMoreIterator, ) -> bool { let mut found_whitespace = false; while let Some(w) = s.peek() { @@ -37,7 +39,7 @@ pub(crate) trait IsComment { } pub(crate) fn devour_whitespace_or_comment>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> SassResult { let mut found_whitespace = false; while let Some(tok) = toks.peek() { @@ -63,7 +65,7 @@ pub(crate) fn devour_whitespace_or_comment>( } pub(crate) fn parse_interpolation>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult> { @@ -95,7 +97,7 @@ impl VariableDecl { // // Does not consume the open curly brace pub(crate) fn read_until_open_curly_brace>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> Vec { let mut val = Vec::new(); let mut n = 0; @@ -123,7 +125,7 @@ pub(crate) fn read_until_open_curly_brace>( } pub(crate) fn read_until_closing_curly_brace>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> Vec { let mut t = Vec::new(); let mut nesting = 0; @@ -161,7 +163,7 @@ pub(crate) fn read_until_closing_curly_brace>( } pub(crate) fn read_until_closing_quote>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, q: char, ) -> Vec { let mut t = Vec::new(); @@ -194,7 +196,7 @@ pub(crate) fn read_until_closing_quote>( } pub(crate) fn read_until_semicolon_or_closing_curly_brace>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> Vec { let mut t = Vec::new(); let mut nesting = 0; @@ -240,7 +242,7 @@ pub(crate) fn read_until_semicolon_or_closing_curly_brace>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> Vec { let mut t = Vec::new(); let mut nesting = 0; @@ -299,7 +301,7 @@ pub(crate) fn read_until_semicolon_or_open_or_closing_curly_brace>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { @@ -308,7 +310,7 @@ pub(crate) fn eat_variable_value>( let mut global = false; let mut raw = read_until_semicolon_or_closing_curly_brace(toks) .into_iter() - .peekable(); + .peekmore(); if toks.peek().is_some() && toks.peek().unwrap().kind == ';' { toks.next(); } @@ -348,7 +350,7 @@ pub(crate) fn eat_variable_value>( } fn ident_body>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, unit: bool, mut span: Span, ) -> SassResult> { @@ -356,8 +358,8 @@ fn ident_body>( while let Some(tok) = toks.peek() { span = span.merge(tok.pos()); if unit && tok.kind == '-' { - todo!() - // Disallow `-` followed by a dot or a digit digit in units. + // Disallow `-` followed by a dot or a digit digit in units. + toks.next(); // var second = scanner.peekChar(1); // if (second != null && (second == $dot || isDigit(second))) break; // text.writeCharCode(scanner.readChar()); @@ -374,7 +376,7 @@ fn ident_body>( } fn interpolated_ident_body>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, mut span: Span, @@ -419,7 +421,7 @@ fn is_name_start(c: char) -> bool { } fn escape>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, identifier_start: bool, ) -> SassResult { let mut value = 0; @@ -475,7 +477,7 @@ fn escape>( } pub(crate) fn eat_ident>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult> { @@ -532,7 +534,7 @@ pub(crate) fn eat_ident>( } pub(crate) fn eat_ident_no_interpolation>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, unit: bool, ) -> SassResult> { let mut span = toks.peek().unwrap().pos(); @@ -569,7 +571,7 @@ pub(crate) fn eat_ident_no_interpolation>( } pub(crate) fn eat_number>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> SassResult> { let mut whole = String::new(); let mut span = if let Some(tok) = toks.peek() { @@ -621,7 +623,7 @@ pub(crate) fn eat_number>( /// We only have to check for \n as the lexing step normalizes all newline characters /// /// The newline is consumed -pub(crate) fn read_until_newline>(toks: &mut Peekable) { +pub(crate) fn read_until_newline>(toks: &mut PeekMoreIterator) { for tok in toks { if tok.kind == '\n' { break; @@ -635,7 +637,7 @@ pub(crate) fn read_until_newline>(toks: &mut Peekable< /// The entirety of the comment, including the ending "*/" is consumed. /// Note that the ending "*/" is not included in the output. pub(crate) fn eat_comment>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult> { @@ -676,7 +678,7 @@ fn as_hex(c: u32) -> u32 { } pub(crate) fn parse_quoted_string>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, q: char, super_selector: &Selector, @@ -753,7 +755,7 @@ pub(crate) fn parse_quoted_string>( } pub(crate) fn read_until_closing_paren>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> Vec { let mut v = Vec::new(); let mut scope = 0; @@ -781,7 +783,7 @@ pub(crate) fn read_until_closing_paren>( } pub(crate) fn read_until_closing_square_brace>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, ) -> Vec { let mut v = Vec::new(); let mut scope = 0; @@ -809,7 +811,7 @@ pub(crate) fn read_until_closing_square_brace>( } pub(crate) fn read_until_char>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, c: char, ) -> Vec { let mut v = Vec::new(); diff --git a/src/value/css_function.rs b/src/value/css_function.rs index c1539be..5832997 100644 --- a/src/value/css_function.rs +++ b/src/value/css_function.rs @@ -1,4 +1,4 @@ -use std::iter::Peekable; +use peekmore::PeekMoreIterator; use crate::error::SassResult; use crate::scope::Scope; @@ -7,7 +7,7 @@ use crate::utils::{devour_whitespace, parse_interpolation}; use crate::Token; pub(crate) fn eat_calc_args>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { @@ -57,7 +57,7 @@ pub(crate) fn is_special_function(s: &str) -> bool { } pub(crate) fn eat_progid>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { diff --git a/src/value/parse.rs b/src/value/parse.rs index 8fd8710..6e94f3d 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -1,5 +1,5 @@ use std::convert::TryFrom; -use std::iter::{Iterator, Peekable}; +use std::iter::Iterator; use std::mem; use num_bigint::BigInt; @@ -8,6 +8,8 @@ use num_traits::pow; use codemap::{Span, Spanned}; +use peekmore::{PeekMore, PeekMoreIterator}; + use super::css_function::{eat_calc_args, eat_progid}; use crate::args::eat_call_args; @@ -30,7 +32,7 @@ use super::map::SassMap; use super::number::Number; fn parse_hex>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, mut span: Span, @@ -140,7 +142,7 @@ fn parse_paren( return Ok(()); } - let paren_toks = &mut t.node.into_iter().peekable(); + let paren_toks = &mut t.node.into_iter().peekmore(); let mut map = SassMap::new(); let key = Value::from_vec(read_until_char(paren_toks, ':'), scope, super_selector)?; @@ -188,7 +190,7 @@ fn parse_paren( } fn eat_op>( - iter: &mut Peekable, + iter: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, op: Spanned, @@ -300,7 +302,7 @@ fn eat_op>( } fn single_value>( - iter: &mut Peekable, + iter: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, span: Span, @@ -363,7 +365,7 @@ fn single_value>( impl Value { pub fn from_tokens>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult> { @@ -379,7 +381,7 @@ impl Value { let mut last_was_whitespace = false; let mut space_separated = Vec::new(); let mut comma_separated = Vec::new(); - let mut iter = intermediate_values.into_iter().peekable(); + let mut iter = intermediate_values.into_iter().peekmore(); while let Some(val) = iter.next() { match val { IntermediateValue::Value(v) => { @@ -484,11 +486,11 @@ impl Value { scope: &Scope, super_selector: &Selector, ) -> SassResult> { - Self::from_tokens(&mut toks.into_iter().peekable(), scope, super_selector) + Self::from_tokens(&mut toks.into_iter().peekmore(), scope, super_selector) } fn ident>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult { @@ -583,7 +585,7 @@ impl Value { } fn parse_intermediate_value>( - toks: &mut Peekable, + toks: &mut PeekMoreIterator, scope: &Scope, super_selector: &Selector, ) -> SassResult {