Skip to content

Commit

Permalink
Avoid tuple-like structs. See rust-lang/rust#7899
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Aug 9, 2013
1 parent 7ef8a5b commit bb35329
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ use ast::*;
/// Return a Iterator<Result<Rule, SyntaxError>>
#[inline]
pub fn parse_stylesheet_rules<T: Iterator<Node>>(iter: T) -> StylesheetParser<T> {
StylesheetParser(iter)
StylesheetParser{ iter: iter }
}


/// Parse a non-top level list of rules eg. the content of an @media rule.
/// Return a Iterator<Result<Rule, SyntaxError>>
#[inline]
pub fn parse_rule_list<T: Iterator<Node>>(iter: T) -> RuleListParser<T> {
RuleListParser(iter)
RuleListParser{ iter: iter }
}


Expand All @@ -41,19 +41,19 @@ pub fn parse_rule_list<T: Iterator<Node>>(iter: T) -> RuleListParser<T> {
/// Return a Iterator<Result<DeclarationListItem, SyntaxError>>
#[inline]
pub fn parse_declaration_list<T: Iterator<Node>>(iter: T) -> DeclarationListParser<T> {
DeclarationListParser(iter)
DeclarationListParser{ iter: iter }
}


/// Parse a single rule.
/// Used eg. for CSSRuleList.insertRule()
pub fn parse_one_rule<T: Iterator<Node>>(iter: T) -> Result<Rule, SyntaxError> {
let mut parser = RuleListParser(iter);
let mut parser = RuleListParser{ iter: iter };
match parser.next() {
None => error(START_LOCATION, ErrEmptyInput),
Some(result) => {
if result.is_err() { result }
else { match next_non_whitespace(&mut *parser) {
else { match next_non_whitespace(&mut parser.iter) {
None => result,
Some((_component_value, location)) => error(location, ErrExtraInput),
}}
Expand Down Expand Up @@ -98,9 +98,9 @@ pub fn parse_one_component_value<T: Iterator<Node>>(mut iter: T)
// *********** End of public API ***********


struct StylesheetParser<T>(T);
struct RuleListParser<T>(T);
struct DeclarationListParser<T>(T);
struct StylesheetParser<T>{ iter: T }
struct RuleListParser<T>{ iter: T }
struct DeclarationListParser<T>{ iter: T }


// Work around "error: cannot borrow `*iter` as mutable more than once at a time"
Expand All @@ -116,7 +116,7 @@ macro_rules! for_iter(

impl<T: Iterator<Node>> Iterator<Result<Rule, SyntaxError>> for StylesheetParser<T> {
fn next(&mut self) -> Option<Result<Rule, SyntaxError>> {
let iter = &mut **self;
let iter = &mut self.iter;
for_iter!(iter, (component_value, location), {
match component_value {
WhiteSpace | CDO | CDC => (),
Expand All @@ -134,7 +134,7 @@ impl<T: Iterator<Node>> Iterator<Result<Rule, SyntaxError>> for StylesheetParser

impl<T: Iterator<Node>> Iterator<Result<Rule, SyntaxError>> for RuleListParser<T> {
fn next(&mut self) -> Option<Result<Rule, SyntaxError>> {
let iter = &mut **self;
let iter = &mut self.iter;
for_iter!(iter, (component_value, location), {
match component_value {
WhiteSpace => (),
Expand All @@ -153,7 +153,7 @@ impl<T: Iterator<Node>> Iterator<Result<Rule, SyntaxError>> for RuleListParser<T
impl<T: Iterator<Node>> Iterator<Result<DeclarationListItem, SyntaxError>>
for DeclarationListParser<T> {
fn next(&mut self) -> Option<Result<DeclarationListItem, SyntaxError>> {
let iter = &mut **self;
let iter = &mut self.iter;
for_iter!(iter, (component_value, location), {
match component_value {
WhiteSpace | Semicolon => (),
Expand Down

0 comments on commit bb35329

Please sign in to comment.