Skip to content

Commit ae4443b

Browse files
committed
Use Parser::try_parse
1 parent 17c4985 commit ae4443b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/color.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ where
608608
NumberOrPercentage::Percentage { unit_value } => (clamp_unit_f32(unit_value), false),
609609
};
610610

611-
let uses_commas = arguments.try(|i| i.expect_comma()).is_ok();
611+
let uses_commas = arguments.try_parse(|i| i.expect_comma()).is_ok();
612612

613613
let green;
614614
let blue;
@@ -647,7 +647,7 @@ where
647647

648648
// Saturation and lightness are clamped to 0% ... 100%
649649
// https://drafts.csswg.org/css-color/#the-hsl-notation
650-
let uses_commas = arguments.try(|i| i.expect_comma()).is_ok();
650+
let uses_commas = arguments.try_parse(|i| i.expect_comma()).is_ok();
651651

652652
let saturation = component_parser.parse_percentage(arguments)?;
653653
let saturation = saturation.max(0.).min(1.);

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Examples:
4545
// 'none' | <image>
4646
fn parse_background_image(context: &ParserContext, input: &mut Parser)
4747
-> Result<Option<Image>, ()> {
48-
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
48+
if input.try_parse(|input| input.expect_ident_matching("none")).is_ok() {
4949
Ok(None)
5050
} else {
5151
Image::parse(context, input).map(Some) // tail call
@@ -58,7 +58,7 @@ fn parse_background_image(context: &ParserContext, input: &mut Parser)
5858
fn parse_border_spacing(_context: &ParserContext, input: &mut Parser)
5959
-> Result<(LengthOrPercentage, LengthOrPercentage), ()> {
6060
let first = LengthOrPercentage::parse?;
61-
let second = input.try(LengthOrPercentage::parse).unwrap_or(first);
61+
let second = input.try_parse(LengthOrPercentage::parse).unwrap_or(first);
6262
(first, second)
6363
}
6464
```

src/rules_and_declarations.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use parser::{parse_nested_block, parse_until_after, parse_until_before, ParserSt
1111

1212
/// Parse `!important`.
1313
///
14-
/// Typical usage is `input.try(parse_important).is_ok()`
14+
/// Typical usage is `input.try_parse(parse_important).is_ok()`
1515
/// at the end of a `DeclarationParser::parse_value` implementation.
1616
pub fn parse_important<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), BasicParseError<'i>> {
1717
input.expect_delim('!')?;
@@ -60,7 +60,7 @@ pub trait DeclarationParser<'i> {
6060
/// (In declaration lists, before the next semicolon or end of the current block.)
6161
///
6262
/// If `!important` can be used in a given context,
63-
/// `input.try(parse_important).is_ok()` should be used at the end
63+
/// `input.try_parse(parse_important).is_ok()` should be used at the end
6464
/// of the implementation of this method and the result should be part of the return value.
6565
fn parse_value<'t>(
6666
&mut self,

src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ fn unquoted_url(b: &mut Bencher) {
815815
let mut input = Parser::new(&mut input);
816816
input.look_for_var_or_env_functions();
817817

818-
let result = input.try(|input| input.expect_url());
818+
let result = input.try_parse(|input| input.expect_url());
819819

820820
assert!(result.is_ok());
821821

0 commit comments

Comments
 (0)