summaryrefslogtreecommitdiffstats
path: root/vendor/pest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/pest/tests')
-rw-r--r--vendor/pest/tests/calculator.rs18
-rw-r--r--vendor/pest/tests/json.rs75
2 files changed, 45 insertions, 48 deletions
diff --git a/vendor/pest/tests/calculator.rs b/vendor/pest/tests/calculator.rs
index b78ee0d27..54a50cc67 100644
--- a/vendor/pest/tests/calculator.rs
+++ b/vendor/pest/tests/calculator.rs
@@ -40,12 +40,12 @@ impl Parser<Rule> for CalculatorParser {
s.repeat(|s| {
s.sequence(|s| {
plus(s)
- .or_else(|s| minus(s))
- .or_else(|s| times(s))
- .or_else(|s| divide(s))
- .or_else(|s| modulus(s))
- .or_else(|s| power(s))
- .and_then(|s| primary(s))
+ .or_else(minus)
+ .or_else(times)
+ .or_else(divide)
+ .or_else(modulus)
+ .or_else(power)
+ .and_then(primary)
})
})
})
@@ -57,10 +57,10 @@ impl Parser<Rule> for CalculatorParser {
state
.sequence(|s| {
s.match_string("(")
- .and_then(|s| expression(s))
+ .and_then(expression)
.and_then(|s| s.match_string(")"))
})
- .or_else(|s| number(s))
+ .or_else(number)
}
fn number(state: Box<ParserState<Rule>>) -> ParseResult<Box<ParserState<Rule>>> {
@@ -109,7 +109,7 @@ impl Parser<Rule> for CalculatorParser {
}
}
-fn consume<'i>(pair: Pair<'i, Rule>, climber: &PrecClimber<Rule>) -> i32 {
+fn consume(pair: Pair<Rule>, climber: &PrecClimber<Rule>) -> i32 {
let primary = |pair| consume(pair, climber);
let infix = |lhs: i32, op: Pair<Rule>, rhs: i32| match op.as_rule() {
Rule::plus => lhs + rhs,
diff --git a/vendor/pest/tests/json.rs b/vendor/pest/tests/json.rs
index 84906258a..b9338c342 100644
--- a/vendor/pest/tests/json.rs
+++ b/vendor/pest/tests/json.rs
@@ -47,16 +47,16 @@ impl Parser<Rule> for JsonParser {
state.rule(Rule::object, |s| {
s.sequence(|s| {
s.match_string("{")
- .and_then(|s| skip(s))
- .and_then(|s| pair(s))
- .and_then(|s| skip(s))
+ .and_then(skip)
+ .and_then(pair)
+ .and_then(skip)
.and_then(|s| {
s.repeat(|s| {
s.sequence(|s| {
s.match_string(",")
- .and_then(|s| skip(s))
- .and_then(|s| pair(s))
- .and_then(|s| skip(s))
+ .and_then(skip)
+ .and_then(pair)
+ .and_then(skip)
})
})
})
@@ -65,7 +65,7 @@ impl Parser<Rule> for JsonParser {
.or_else(|s| {
s.sequence(|s| {
s.match_string("{")
- .and_then(|s| skip(s))
+ .and_then(skip)
.and_then(|s| s.match_string("}"))
})
})
@@ -76,10 +76,10 @@ impl Parser<Rule> for JsonParser {
state.rule(Rule::pair, |s| {
s.sequence(|s| {
string(s)
- .and_then(|s| skip(s))
+ .and_then(skip)
.and_then(|s| s.match_string(":"))
- .and_then(|s| skip(s))
- .and_then(|s| value(s))
+ .and_then(skip)
+ .and_then(value)
})
})
}
@@ -88,16 +88,16 @@ impl Parser<Rule> for JsonParser {
state.rule(Rule::array, |s| {
s.sequence(|s| {
s.match_string("[")
- .and_then(|s| skip(s))
- .and_then(|s| value(s))
- .and_then(|s| skip(s))
+ .and_then(skip)
+ .and_then(value)
+ .and_then(skip)
.and_then(|s| {
s.repeat(|s| {
s.sequence(|s| {
s.match_string(",")
- .and_then(|s| skip(s))
- .and_then(|s| value(s))
- .and_then(|s| skip(s))
+ .and_then(skip)
+ .and_then(value)
+ .and_then(skip)
})
})
})
@@ -106,7 +106,7 @@ impl Parser<Rule> for JsonParser {
.or_else(|s| {
s.sequence(|s| {
s.match_string("[")
- .and_then(|s| skip(s))
+ .and_then(skip)
.and_then(|s| s.match_string("]"))
})
})
@@ -116,11 +116,11 @@ impl Parser<Rule> for JsonParser {
fn value(state: Box<ParserState<Rule>>) -> ParseResult<Box<ParserState<Rule>>> {
state.rule(Rule::value, |s| {
string(s)
- .or_else(|s| number(s))
- .or_else(|s| object(s))
- .or_else(|s| array(s))
- .or_else(|s| bool(s))
- .or_else(|s| null(s))
+ .or_else(number)
+ .or_else(object)
+ .or_else(array)
+ .or_else(bool)
+ .or_else(null)
})
}
@@ -154,7 +154,7 @@ impl Parser<Rule> for JsonParser {
.or_else(|s| s.match_string("n"))
.or_else(|s| s.match_string("r"))
.or_else(|s| s.match_string("t"))
- .or_else(|s| unicode(s))
+ .or_else(unicode)
})
})
}
@@ -162,9 +162,9 @@ impl Parser<Rule> for JsonParser {
fn unicode(state: Box<ParserState<Rule>>) -> ParseResult<Box<ParserState<Rule>>> {
state.sequence(|s| {
s.match_string("u")
- .and_then(|s| hex(s))
- .and_then(|s| hex(s))
- .and_then(|s| hex(s))
+ .and_then(hex)
+ .and_then(hex)
+ .and_then(hex)
})
}
@@ -179,15 +179,15 @@ impl Parser<Rule> for JsonParser {
state.rule(Rule::number, |s| {
s.sequence(|s| {
s.optional(|s| s.match_string("-"))
- .and_then(|s| int(s))
+ .and_then(int)
.and_then(|s| {
s.optional(|s| {
s.sequence(|s| {
s.match_string(".")
.and_then(|s| s.match_range('0'..'9'))
.and_then(|s| s.repeat(|s| s.match_range('0'..'9')))
- .and_then(|s| s.optional(|s| exp(s)))
- .or_else(|s| exp(s))
+ .and_then(|s| s.optional(exp))
+ .or_else(exp)
})
})
})
@@ -211,7 +211,7 @@ impl Parser<Rule> for JsonParser {
.and_then(|s| {
s.optional(|s| s.match_string("+").or_else(|s| s.match_string("-")))
})
- .and_then(|s| int(s))
+ .and_then(int)
})
}
@@ -451,15 +451,12 @@ fn ast() {
.unwrap(),
);
- match ast {
- Json::Object(pairs) => {
- let vals: Vec<&Json> = pairs.values().collect();
+ if let Json::Object(pairs) = ast {
+ let vals: Vec<&Json> = pairs.values().collect();
- assert_eq!(
- **vals.get(0).unwrap(),
- Json::Array(vec![Json::Null, Json::Bool(true), Json::Number(3.4)])
- );
- }
- _ => {}
+ assert_eq!(
+ **vals.get(0).unwrap(),
+ Json::Array(vec![Json::Null, Json::Bool(true), Json::Number(3.4)])
+ );
}
}