Skip to content

Commit c754931

Browse files
author
bors-servo
authored
Auto merge of #244 - servo:try_parse, r=emilio
Add Parser::try_parse, same as Parser::try Fixes #243 Note that we are not (so far) emitting deprecation warnings for the old name. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/244) <!-- Reviewable:end -->
2 parents dd75c5d + 626100d commit c754931

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.25.3"
3+
version = "0.25.4"
44
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
55

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

src/parser.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,19 @@ impl<'i: 't, 't> Parser<'i, 't> {
495495
self.input.tokenizer.seen_var_or_env_functions()
496496
}
497497

498+
/// The old name of `try_parse`, which requires raw identifiers in the Rust 2018 edition.
499+
#[inline]
500+
pub fn try<F, T, E>(&mut self, thing: F) -> Result<T, E>
501+
where F: FnOnce(&mut Parser<'i, 't>) -> Result<T, E> {
502+
self.try_parse(thing)
503+
}
504+
498505
/// Execute the given closure, passing it the parser.
499506
/// If the result (returned unchanged) is `Err`,
500507
/// the internal state of the parser (including position within the input)
501508
/// is restored to what it was before the call.
502509
#[inline]
503-
pub fn try<F, T, E>(&mut self, thing: F) -> Result<T, E>
510+
pub fn try_parse<F, T, E>(&mut self, thing: F) -> Result<T, E>
504511
where F: FnOnce(&mut Parser<'i, 't>) -> Result<T, E> {
505512
let start = self.state();
506513
let result = thing(self);

0 commit comments

Comments
 (0)