Skip to content

Commit bb35329

Browse files
committed
Avoid tuple-like structs. See rust-lang/rust#7899
1 parent 7ef8a5b commit bb35329

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

parser.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ use ast::*;
2424
/// Return a Iterator<Result<Rule, SyntaxError>>
2525
#[inline]
2626
pub fn parse_stylesheet_rules<T: Iterator<Node>>(iter: T) -> StylesheetParser<T> {
27-
StylesheetParser(iter)
27+
StylesheetParser{ iter: iter }
2828
}
2929

3030

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

3838

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

4747

4848
/// Parse a single rule.
4949
/// Used eg. for CSSRuleList.insertRule()
5050
pub fn parse_one_rule<T: Iterator<Node>>(iter: T) -> Result<Rule, SyntaxError> {
51-
let mut parser = RuleListParser(iter);
51+
let mut parser = RuleListParser{ iter: iter };
5252
match parser.next() {
5353
None => error(START_LOCATION, ErrEmptyInput),
5454
Some(result) => {
5555
if result.is_err() { result }
56-
else { match next_non_whitespace(&mut *parser) {
56+
else { match next_non_whitespace(&mut parser.iter) {
5757
None => result,
5858
Some((_component_value, location)) => error(location, ErrExtraInput),
5959
}}
@@ -98,9 +98,9 @@ pub fn parse_one_component_value<T: Iterator<Node>>(mut iter: T)
9898
// *********** End of public API ***********
9999

100100

101-
struct StylesheetParser<T>(T);
102-
struct RuleListParser<T>(T);
103-
struct DeclarationListParser<T>(T);
101+
struct StylesheetParser<T>{ iter: T }
102+
struct RuleListParser<T>{ iter: T }
103+
struct DeclarationListParser<T>{ iter: T }
104104

105105

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

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

135135
impl<T: Iterator<Node>> Iterator<Result<Rule, SyntaxError>> for RuleListParser<T> {
136136
fn next(&mut self) -> Option<Result<Rule, SyntaxError>> {
137-
let iter = &mut **self;
137+
let iter = &mut self.iter;
138138
for_iter!(iter, (component_value, location), {
139139
match component_value {
140140
WhiteSpace => (),
@@ -153,7 +153,7 @@ impl<T: Iterator<Node>> Iterator<Result<Rule, SyntaxError>> for RuleListParser<T
153153
impl<T: Iterator<Node>> Iterator<Result<DeclarationListItem, SyntaxError>>
154154
for DeclarationListParser<T> {
155155
fn next(&mut self) -> Option<Result<DeclarationListItem, SyntaxError>> {
156-
let iter = &mut **self;
156+
let iter = &mut self.iter;
157157
for_iter!(iter, (component_value, location), {
158158
match component_value {
159159
WhiteSpace | Semicolon => (),

0 commit comments

Comments
 (0)