Skip to content

Commit 753bafe

Browse files
Remove the dependency on boolinator (#3420)
* removed boolinator from dependencies of yew-macro * removed boolinator from the dependencies of tools/website-test * fixed formatting * removed a lint fix
1 parent fef685b commit 753bafe

File tree

8 files changed

+37
-36
lines changed

8 files changed

+37
-36
lines changed

Cargo.lock

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/yew-macro/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ rust-version = "1.64.0"
1616
proc-macro = true
1717

1818
[dependencies]
19-
boolinator = "2"
2019
proc-macro-error = "1"
2120
proc-macro2 = "1"
2221
quote = "1"

packages/yew-macro/src/html_tree/html_dashed_name.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::fmt;
22

3-
use boolinator::Boolinator;
43
use proc_macro2::{Ident, Span, TokenStream};
54
use quote::{quote, ToTokens};
65
use syn::buffer::Cursor;
@@ -54,7 +53,9 @@ impl fmt::Display for HtmlDashedName {
5453
impl Peek<'_, Self> for HtmlDashedName {
5554
fn peek(cursor: Cursor) -> Option<(Self, Cursor)> {
5655
let (name, cursor) = cursor.ident()?;
57-
non_capitalized_ascii(&name.to_string()).as_option()?;
56+
if !non_capitalized_ascii(&name.to_string()) {
57+
return None;
58+
}
5859

5960
let mut extended = Vec::new();
6061
let mut cursor = cursor;

packages/yew-macro/src/html_tree/html_element.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use boolinator::Boolinator;
21
use proc_macro2::{Delimiter, Span, TokenStream};
32
use proc_macro_error::emit_warning;
43
use quote::{quote, quote_spanned, ToTokens};
@@ -507,7 +506,9 @@ pub struct DynamicName {
507506
impl Peek<'_, ()> for DynamicName {
508507
fn peek(cursor: Cursor) -> Option<((), Cursor)> {
509508
let (punct, cursor) = cursor.punct()?;
510-
(punct.as_char() == '@').as_option()?;
509+
if punct.as_char() != '@' {
510+
return None;
511+
}
511512

512513
// move cursor past block if there is one
513514
let cursor = cursor
@@ -607,17 +608,21 @@ impl HtmlElementOpen {
607608
impl PeekValue<TagKey> for HtmlElementOpen {
608609
fn peek(cursor: Cursor) -> Option<TagKey> {
609610
let (punct, cursor) = cursor.punct()?;
610-
(punct.as_char() == '<').as_option()?;
611+
if punct.as_char() != '<' {
612+
return None;
613+
}
611614

612615
let (tag_key, cursor) = TagName::peek(cursor)?;
613616
if let TagKey::Lit(name) = &tag_key {
614617
// Avoid parsing `<key=[...]>` as an element. It needs to be parsed as an `HtmlList`.
615618
if name.to_string() == "key" {
616619
let (punct, _) = cursor.punct()?;
617620
// ... 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;
621626
}
622627
}
623628

@@ -675,20 +680,22 @@ impl HtmlElementClose {
675680
impl PeekValue<TagKey> for HtmlElementClose {
676681
fn peek(cursor: Cursor) -> Option<TagKey> {
677682
let (punct, cursor) = cursor.punct()?;
678-
(punct.as_char() == '<').as_option()?;
683+
if punct.as_char() != '<' {
684+
return None;
685+
}
679686

680687
let (punct, cursor) = cursor.punct()?;
681-
(punct.as_char() == '/').as_option()?;
688+
if punct.as_char() != '/' {
689+
return None;
690+
}
682691

683692
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;
686695
}
687696

688697
let (punct, _) = cursor.punct()?;
689-
(punct.as_char() == '>').as_option()?;
690-
691-
Some(tag_key)
698+
(punct.as_char() == '>').then_some(tag_key)
692699
}
693700
}
694701

packages/yew-macro/src/html_tree/html_if.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use boolinator::Boolinator;
21
use proc_macro2::TokenStream;
32
use quote::{quote_spanned, ToTokens};
43
use syn::buffer::Cursor;
@@ -19,7 +18,7 @@ pub struct HtmlIf {
1918
impl PeekValue<()> for HtmlIf {
2019
fn peek(cursor: Cursor) -> Option<()> {
2120
let (ident, _) = cursor.ident()?;
22-
(ident == "if").as_option()
21+
(ident == "if").then_some(())
2322
}
2423
}
2524

packages/yew-macro/src/html_tree/html_iterable.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use boolinator::Boolinator;
21
use proc_macro2::TokenStream;
32
use quote::{quote_spanned, ToTokens};
43
use syn::buffer::Cursor;
@@ -14,7 +13,7 @@ pub struct HtmlIterable(Expr);
1413
impl PeekValue<()> for HtmlIterable {
1514
fn peek(cursor: Cursor) -> Option<()> {
1615
let (ident, _) = cursor.ident()?;
17-
(ident == "for").as_option()
16+
(ident == "for").then_some(())
1817
}
1918
}
2019

packages/yew-macro/src/html_tree/html_list.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use boolinator::Boolinator;
21
use quote::{quote, quote_spanned, ToTokens};
32
use syn::buffer::Cursor;
43
use syn::parse::{Parse, ParseStream};
@@ -99,14 +98,16 @@ impl HtmlListOpen {
9998
impl PeekValue<()> for HtmlListOpen {
10099
fn peek(cursor: Cursor) -> Option<()> {
101100
let (punct, cursor) = cursor.punct()?;
102-
(punct.as_char() == '<').as_option()?;
101+
if punct.as_char() != '<' {
102+
return None;
103+
}
103104
// make sure it's either a property (key=value) or it's immediately closed
104105
if let Some((_, cursor)) = HtmlDashedName::peek(cursor) {
105106
let (punct, _) = cursor.punct()?;
106-
(punct.as_char() == '=' || punct.as_char() == '?').as_option()
107+
(punct.as_char() == '=' || punct.as_char() == '?').then_some(())
107108
} else {
108109
let (punct, _) = cursor.punct()?;
109-
(punct.as_char() == '>').as_option()
110+
(punct.as_char() == '>').then_some(())
110111
}
111112
}
112113
}
@@ -156,12 +157,16 @@ impl HtmlListClose {
156157
impl PeekValue<()> for HtmlListClose {
157158
fn peek(cursor: Cursor) -> Option<()> {
158159
let (punct, cursor) = cursor.punct()?;
159-
(punct.as_char() == '<').as_option()?;
160+
if punct.as_char() != '<' {
161+
return None;
162+
}
160163
let (punct, cursor) = cursor.punct()?;
161-
(punct.as_char() == '/').as_option()?;
164+
if punct.as_char() != '/' {
165+
return None;
166+
}
162167

163168
let (punct, _) = cursor.punct()?;
164-
(punct.as_char() == '>').as_option()
169+
(punct.as_char() == '>').then_some(())
165170
}
166171
}
167172
impl Parse for HtmlListClose {

tools/website-test/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ rust-version = "1.62"
1010
yew-agent = { path = "../../packages/yew-agent/" }
1111

1212
[dev-dependencies]
13-
boolinator = "2.4"
1413
derive_more = "0.99"
1514
gloo = "0.10"
1615
js-sys = "0.3"

0 commit comments

Comments
 (0)