|
1 | | -use boolinator::Boolinator; |
2 | 1 | use proc_macro2::{Delimiter, Span, TokenStream}; |
3 | 2 | use proc_macro_error::emit_warning; |
4 | 3 | use quote::{quote, quote_spanned, ToTokens}; |
@@ -507,7 +506,9 @@ pub struct DynamicName { |
507 | 506 | impl Peek<'_, ()> for DynamicName { |
508 | 507 | fn peek(cursor: Cursor) -> Option<((), Cursor)> { |
509 | 508 | let (punct, cursor) = cursor.punct()?; |
510 | | - (punct.as_char() == '@').as_option()?; |
| 509 | + if punct.as_char() != '@' { |
| 510 | + return None; |
| 511 | + } |
511 | 512 |
|
512 | 513 | // move cursor past block if there is one |
513 | 514 | let cursor = cursor |
@@ -607,17 +608,21 @@ impl HtmlElementOpen { |
607 | 608 | impl PeekValue<TagKey> for HtmlElementOpen { |
608 | 609 | fn peek(cursor: Cursor) -> Option<TagKey> { |
609 | 610 | let (punct, cursor) = cursor.punct()?; |
610 | | - (punct.as_char() == '<').as_option()?; |
| 611 | + if punct.as_char() != '<' { |
| 612 | + return None; |
| 613 | + } |
611 | 614 |
|
612 | 615 | let (tag_key, cursor) = TagName::peek(cursor)?; |
613 | 616 | if let TagKey::Lit(name) = &tag_key { |
614 | 617 | // Avoid parsing `<key=[...]>` as an element. It needs to be parsed as an `HtmlList`. |
615 | 618 | if name.to_string() == "key" { |
616 | 619 | let (punct, _) = cursor.punct()?; |
617 | 620 | // ... unless it isn't followed by a '='. `<key></key>` is a valid element! |
618 | | - (punct.as_char() != '=').as_option()?; |
619 | | - } else { |
620 | | - non_capitalized_ascii(&name.to_string()).as_option()?; |
| 621 | + if punct.as_char() == '=' { |
| 622 | + return None; |
| 623 | + } |
| 624 | + } else if !non_capitalized_ascii(&name.to_string()) { |
| 625 | + return None; |
621 | 626 | } |
622 | 627 | } |
623 | 628 |
|
@@ -675,20 +680,22 @@ impl HtmlElementClose { |
675 | 680 | impl PeekValue<TagKey> for HtmlElementClose { |
676 | 681 | fn peek(cursor: Cursor) -> Option<TagKey> { |
677 | 682 | let (punct, cursor) = cursor.punct()?; |
678 | | - (punct.as_char() == '<').as_option()?; |
| 683 | + if punct.as_char() != '<' { |
| 684 | + return None; |
| 685 | + } |
679 | 686 |
|
680 | 687 | let (punct, cursor) = cursor.punct()?; |
681 | | - (punct.as_char() == '/').as_option()?; |
| 688 | + if punct.as_char() != '/' { |
| 689 | + return None; |
| 690 | + } |
682 | 691 |
|
683 | 692 | let (tag_key, cursor) = TagName::peek(cursor)?; |
684 | | - if let TagKey::Lit(name) = &tag_key { |
685 | | - non_capitalized_ascii(&name.to_string()).as_option()?; |
| 693 | + if matches!(&tag_key, TagKey::Lit(name) if !non_capitalized_ascii(&name.to_string())) { |
| 694 | + return None; |
686 | 695 | } |
687 | 696 |
|
688 | 697 | let (punct, _) = cursor.punct()?; |
689 | | - (punct.as_char() == '>').as_option()?; |
690 | | - |
691 | | - Some(tag_key) |
| 698 | + (punct.as_char() == '>').then_some(tag_key) |
692 | 699 | } |
693 | 700 | } |
694 | 701 |
|
|
0 commit comments