mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Switch all callsites of try() to try_parse() in the style crate.
Fully automated via: $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g' $ cd servo/components/style && cargo +nightly fmt Differential Revision: https://phabricator.services.mozilla.com/D80099
This commit is contained in:
parent
5af0d7ca7c
commit
685e749cfc
56 changed files with 469 additions and 403 deletions
|
@ -41,11 +41,16 @@ impl Parse for InitialLetter {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
if input
|
||||
.try_parse(|i| i.expect_ident_matching("normal"))
|
||||
.is_ok()
|
||||
{
|
||||
return Ok(GenericInitialLetter::Normal);
|
||||
}
|
||||
let size = Number::parse_at_least_one(context, input)?;
|
||||
let sink = input.try(|i| Integer::parse_positive(context, i)).ok();
|
||||
let sink = input
|
||||
.try_parse(|i| Integer::parse_positive(context, i))
|
||||
.ok();
|
||||
Ok(GenericInitialLetter::Specified(size, sink))
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +166,7 @@ impl Parse for TextOverflow {
|
|||
) -> Result<TextOverflow, ParseError<'i>> {
|
||||
let first = TextOverflowSide::parse(context, input)?;
|
||||
let second = input
|
||||
.try(|input| TextOverflowSide::parse(context, input))
|
||||
.try_parse(|input| TextOverflowSide::parse(context, input))
|
||||
.ok();
|
||||
Ok(TextOverflow { first, second })
|
||||
}
|
||||
|
@ -251,7 +256,7 @@ impl Parse for TextDecorationLine {
|
|||
// ensure we don't return an error if we don't consume the whole thing
|
||||
// because we find an invalid identifier or other kind of token.
|
||||
loop {
|
||||
let flag: Result<_, ParseError<'i>> = input.try(|input| {
|
||||
let flag: Result<_, ParseError<'i>> = input.try_parse(|input| {
|
||||
let flag = try_match_ident_ignore_ascii_case! { input,
|
||||
"none" if result.is_empty() => TextDecorationLine::NONE,
|
||||
"underline" => TextDecorationLine::UNDERLINE,
|
||||
|
@ -791,22 +796,22 @@ impl Parse for TextEmphasisStyle {
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input
|
||||
.try(|input| input.expect_ident_matching("none"))
|
||||
.try_parse(|input| input.expect_ident_matching("none"))
|
||||
.is_ok()
|
||||
{
|
||||
return Ok(TextEmphasisStyle::None);
|
||||
}
|
||||
|
||||
if let Ok(s) = input.try(|i| i.expect_string().map(|s| s.as_ref().to_owned())) {
|
||||
if let Ok(s) = input.try_parse(|i| i.expect_string().map(|s| s.as_ref().to_owned())) {
|
||||
// Handle <string>
|
||||
return Ok(TextEmphasisStyle::String(s.into()));
|
||||
}
|
||||
|
||||
// Handle a pair of keywords
|
||||
let mut shape = input.try(TextEmphasisShapeKeyword::parse).ok();
|
||||
let fill = input.try(TextEmphasisFillMode::parse).ok();
|
||||
let mut shape = input.try_parse(TextEmphasisShapeKeyword::parse).ok();
|
||||
let fill = input.try_parse(TextEmphasisFillMode::parse).ok();
|
||||
if shape.is_none() {
|
||||
shape = input.try(TextEmphasisShapeKeyword::parse).ok();
|
||||
shape = input.try_parse(TextEmphasisShapeKeyword::parse).ok();
|
||||
}
|
||||
|
||||
if shape.is_none() && fill.is_none() {
|
||||
|
@ -922,7 +927,7 @@ impl Parse for TextEmphasisPosition {
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(horizontal) =
|
||||
input.try(|input| TextEmphasisHorizontalWritingModeValue::parse(input))
|
||||
input.try_parse(|input| TextEmphasisHorizontalWritingModeValue::parse(input))
|
||||
{
|
||||
let vertical = TextEmphasisVerticalWritingModeValue::parse(input)?;
|
||||
Ok(TextEmphasisPosition(horizontal, vertical))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue