Skip to content

Commit 09cedca

Browse files
committed
Make rules and declarations parsers take &mut self
1 parent b53ca32 commit 09cedca

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "cssparser"
4-
version = "0.6.0"
4+
version = "0.7.0"
55
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
66

77
description = "Rust implementation of CSS Syntax Level 3"

src/rules_and_declarations.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub trait DeclarationParser {
6969
/// If `!important` can be used in a given context,
7070
/// `input.try(parse_important).is_ok()` should be used at the end
7171
/// of the implementation of this method and the result should be part of the return value.
72-
fn parse_value(&self, name: &str, input: &mut Parser) -> Result<Self::Declaration, ()>;
72+
fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result<Self::Declaration, ()>;
7373
}
7474

7575

@@ -106,7 +106,7 @@ pub trait AtRuleParser {
106106
/// The given `input` is a "delimited" parser
107107
/// that ends wherever the prelude should end.
108108
/// (Before the next semicolon, the next `{`, or the end of the current block.)
109-
fn parse_prelude(&self, name: &str, input: &mut Parser)
109+
fn parse_prelude(&mut self, name: &str, input: &mut Parser)
110110
-> Result<AtRuleType<Self::Prelude, Self::AtRule>, ()> {
111111
let _ = name;
112112
let _ = input;
@@ -121,7 +121,7 @@ pub trait AtRuleParser {
121121
///
122122
/// This is only called when `parse_prelude` returned `WithBlock` or `OptionalBlock`,
123123
/// and a block was indeed found following the prelude.
124-
fn parse_block(&self, prelude: Self::Prelude, input: &mut Parser)
124+
fn parse_block(&mut self, prelude: Self::Prelude, input: &mut Parser)
125125
-> Result<Self::AtRule, ()> {
126126
let _ = prelude;
127127
let _ = input;
@@ -132,7 +132,7 @@ pub trait AtRuleParser {
132132
///
133133
/// Convert the prelude into the finished representation of the at-rule
134134
/// as returned by `RuleListParser::next` or `DeclarationListParser::next`.
135-
fn rule_without_block(&self, prelude: Self::Prelude) -> Self::AtRule {
135+
fn rule_without_block(&mut self, prelude: Self::Prelude) -> Self::AtRule {
136136
let _ = prelude;
137137
panic!("The `AtRuleParser::rule_without_block` method must be overriden \
138138
if `AtRuleParser::parse_prelude` ever returns `AtRuleType::OptionalBlock`.")
@@ -166,7 +166,7 @@ pub trait QualifiedRuleParser {
166166
///
167167
/// The given `input` is a "delimited" parser
168168
/// that ends where the prelude should end (before the next `{`).
169-
fn parse_prelude(&self, input: &mut Parser) -> Result<Self::Prelude, ()> {
169+
fn parse_prelude(&mut self, input: &mut Parser) -> Result<Self::Prelude, ()> {
170170
let _ = input;
171171
Err(())
172172
}
@@ -176,7 +176,7 @@ pub trait QualifiedRuleParser {
176176
/// Return the finished representation of the qualified rule
177177
/// as returned by `RuleListParser::next`,
178178
/// or `Err(())` to ignore the entire at-rule as invalid.
179-
fn parse_block(&self, prelude: Self::Prelude, input: &mut Parser)
179+
fn parse_block(&mut self, prelude: Self::Prelude, input: &mut Parser)
180180
-> Result<Self::QualifiedRule, ()> {
181181
let _ = prelude;
182182
let _ = input;

src/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ struct JsonParser;
583583
impl DeclarationParser for JsonParser {
584584
type Declaration = Json;
585585

586-
fn parse_value(&self, name: &str, input: &mut Parser) -> Result<Json, ()> {
586+
fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result<Json, ()> {
587587
let mut value = vec![];
588588
let mut important = false;
589589
loop {
@@ -622,7 +622,7 @@ impl AtRuleParser for JsonParser {
622622
type Prelude = Vec<Json>;
623623
type AtRule = Json;
624624

625-
fn parse_prelude(&self, name: &str, input: &mut Parser)
625+
fn parse_prelude(&mut self, name: &str, input: &mut Parser)
626626
-> Result<AtRuleType<Vec<Json>, Json>, ()> {
627627
Ok(AtRuleType::OptionalBlock(vec![
628628
"at-rule".to_json(),
@@ -631,12 +631,12 @@ impl AtRuleParser for JsonParser {
631631
]))
632632
}
633633

634-
fn parse_block(&self, mut prelude: Vec<Json>, input: &mut Parser) -> Result<Json, ()> {
634+
fn parse_block(&mut self, mut prelude: Vec<Json>, input: &mut Parser) -> Result<Json, ()> {
635635
prelude.push(Json::Array(component_values_to_json(input)));
636636
Ok(Json::Array(prelude))
637637
}
638638

639-
fn rule_without_block(&self, mut prelude: Vec<Json>) -> Json {
639+
fn rule_without_block(&mut self, mut prelude: Vec<Json>) -> Json {
640640
prelude.push(Json::Null);
641641
Json::Array(prelude)
642642
}
@@ -646,11 +646,11 @@ impl QualifiedRuleParser for JsonParser {
646646
type Prelude = Vec<Json>;
647647
type QualifiedRule = Json;
648648

649-
fn parse_prelude(&self, input: &mut Parser) -> Result<Vec<Json>, ()> {
649+
fn parse_prelude(&mut self, input: &mut Parser) -> Result<Vec<Json>, ()> {
650650
Ok(component_values_to_json(input))
651651
}
652652

653-
fn parse_block(&self, prelude: Vec<Json>, input: &mut Parser) -> Result<Json, ()> {
653+
fn parse_block(&mut self, prelude: Vec<Json>, input: &mut Parser) -> Result<Json, ()> {
654654
Ok(JArray![
655655
"qualified rule",
656656
prelude,

0 commit comments

Comments
 (0)