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
This commit is contained in:
Tim Kurdov 2023-09-29 12:33:24 +01:00 committed by GitHub
parent fef685ba7d
commit 753bafefdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 36 deletions

8
Cargo.lock generated
View File

@ -313,12 +313,6 @@ dependencies = [
"yew", "yew",
] ]
[[package]]
name = "boolinator"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.13.0" version = "3.13.0"
@ -3467,7 +3461,6 @@ dependencies = [
name = "website-test" name = "website-test"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"boolinator",
"derive_more", "derive_more",
"glob", "glob",
"gloo 0.10.0", "gloo 0.10.0",
@ -3744,7 +3737,6 @@ dependencies = [
name = "yew-macro" name = "yew-macro"
version = "0.21.0" version = "0.21.0"
dependencies = [ dependencies = [
"boolinator",
"once_cell", "once_cell",
"prettyplease", "prettyplease",
"proc-macro-error", "proc-macro-error",

View File

@ -16,7 +16,6 @@ rust-version = "1.64.0"
proc-macro = true proc-macro = true
[dependencies] [dependencies]
boolinator = "2"
proc-macro-error = "1" proc-macro-error = "1"
proc-macro2 = "1" proc-macro2 = "1"
quote = "1" quote = "1"

View File

@ -1,6 +1,5 @@
use std::fmt; use std::fmt;
use boolinator::Boolinator;
use proc_macro2::{Ident, Span, TokenStream}; use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote, ToTokens}; use quote::{quote, ToTokens};
use syn::buffer::Cursor; use syn::buffer::Cursor;
@ -54,7 +53,9 @@ impl fmt::Display for HtmlDashedName {
impl Peek<'_, Self> for HtmlDashedName { impl Peek<'_, Self> for HtmlDashedName {
fn peek(cursor: Cursor) -> Option<(Self, Cursor)> { fn peek(cursor: Cursor) -> Option<(Self, Cursor)> {
let (name, cursor) = cursor.ident()?; let (name, cursor) = cursor.ident()?;
non_capitalized_ascii(&name.to_string()).as_option()?; if !non_capitalized_ascii(&name.to_string()) {
return None;
}
let mut extended = Vec::new(); let mut extended = Vec::new();
let mut cursor = cursor; let mut cursor = cursor;

View File

@ -1,4 +1,3 @@
use boolinator::Boolinator;
use proc_macro2::{Delimiter, Span, TokenStream}; use proc_macro2::{Delimiter, Span, TokenStream};
use proc_macro_error::emit_warning; use proc_macro_error::emit_warning;
use quote::{quote, quote_spanned, ToTokens}; use quote::{quote, quote_spanned, ToTokens};
@ -507,7 +506,9 @@ pub struct DynamicName {
impl Peek<'_, ()> for DynamicName { impl Peek<'_, ()> for DynamicName {
fn peek(cursor: Cursor) -> Option<((), Cursor)> { fn peek(cursor: Cursor) -> Option<((), Cursor)> {
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '@').as_option()?; if punct.as_char() != '@' {
return None;
}
// move cursor past block if there is one // move cursor past block if there is one
let cursor = cursor let cursor = cursor
@ -607,7 +608,9 @@ impl HtmlElementOpen {
impl PeekValue<TagKey> for HtmlElementOpen { impl PeekValue<TagKey> for HtmlElementOpen {
fn peek(cursor: Cursor) -> Option<TagKey> { fn peek(cursor: Cursor) -> Option<TagKey> {
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '<').as_option()?; if punct.as_char() != '<' {
return None;
}
let (tag_key, cursor) = TagName::peek(cursor)?; let (tag_key, cursor) = TagName::peek(cursor)?;
if let TagKey::Lit(name) = &tag_key { if let TagKey::Lit(name) = &tag_key {
@ -615,9 +618,11 @@ impl PeekValue<TagKey> for HtmlElementOpen {
if name.to_string() == "key" { if name.to_string() == "key" {
let (punct, _) = cursor.punct()?; let (punct, _) = cursor.punct()?;
// ... unless it isn't followed by a '='. `<key></key>` is a valid element! // ... unless it isn't followed by a '='. `<key></key>` is a valid element!
(punct.as_char() != '=').as_option()?; if punct.as_char() == '=' {
} else { return None;
non_capitalized_ascii(&name.to_string()).as_option()?; }
} else if !non_capitalized_ascii(&name.to_string()) {
return None;
} }
} }
@ -675,20 +680,22 @@ impl HtmlElementClose {
impl PeekValue<TagKey> for HtmlElementClose { impl PeekValue<TagKey> for HtmlElementClose {
fn peek(cursor: Cursor) -> Option<TagKey> { fn peek(cursor: Cursor) -> Option<TagKey> {
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '<').as_option()?; if punct.as_char() != '<' {
return None;
}
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '/').as_option()?; if punct.as_char() != '/' {
return None;
}
let (tag_key, cursor) = TagName::peek(cursor)?; let (tag_key, cursor) = TagName::peek(cursor)?;
if let TagKey::Lit(name) = &tag_key { if matches!(&tag_key, TagKey::Lit(name) if !non_capitalized_ascii(&name.to_string())) {
non_capitalized_ascii(&name.to_string()).as_option()?; return None;
} }
let (punct, _) = cursor.punct()?; let (punct, _) = cursor.punct()?;
(punct.as_char() == '>').as_option()?; (punct.as_char() == '>').then_some(tag_key)
Some(tag_key)
} }
} }

View File

@ -1,4 +1,3 @@
use boolinator::Boolinator;
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::{quote_spanned, ToTokens}; use quote::{quote_spanned, ToTokens};
use syn::buffer::Cursor; use syn::buffer::Cursor;
@ -19,7 +18,7 @@ pub struct HtmlIf {
impl PeekValue<()> for HtmlIf { impl PeekValue<()> for HtmlIf {
fn peek(cursor: Cursor) -> Option<()> { fn peek(cursor: Cursor) -> Option<()> {
let (ident, _) = cursor.ident()?; let (ident, _) = cursor.ident()?;
(ident == "if").as_option() (ident == "if").then_some(())
} }
} }

View File

@ -1,4 +1,3 @@
use boolinator::Boolinator;
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::{quote_spanned, ToTokens}; use quote::{quote_spanned, ToTokens};
use syn::buffer::Cursor; use syn::buffer::Cursor;
@ -14,7 +13,7 @@ pub struct HtmlIterable(Expr);
impl PeekValue<()> for HtmlIterable { impl PeekValue<()> for HtmlIterable {
fn peek(cursor: Cursor) -> Option<()> { fn peek(cursor: Cursor) -> Option<()> {
let (ident, _) = cursor.ident()?; let (ident, _) = cursor.ident()?;
(ident == "for").as_option() (ident == "for").then_some(())
} }
} }

View File

@ -1,4 +1,3 @@
use boolinator::Boolinator;
use quote::{quote, quote_spanned, ToTokens}; use quote::{quote, quote_spanned, ToTokens};
use syn::buffer::Cursor; use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream}; use syn::parse::{Parse, ParseStream};
@ -99,14 +98,16 @@ impl HtmlListOpen {
impl PeekValue<()> for HtmlListOpen { impl PeekValue<()> for HtmlListOpen {
fn peek(cursor: Cursor) -> Option<()> { fn peek(cursor: Cursor) -> Option<()> {
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '<').as_option()?; if punct.as_char() != '<' {
return None;
}
// make sure it's either a property (key=value) or it's immediately closed // make sure it's either a property (key=value) or it's immediately closed
if let Some((_, cursor)) = HtmlDashedName::peek(cursor) { if let Some((_, cursor)) = HtmlDashedName::peek(cursor) {
let (punct, _) = cursor.punct()?; let (punct, _) = cursor.punct()?;
(punct.as_char() == '=' || punct.as_char() == '?').as_option() (punct.as_char() == '=' || punct.as_char() == '?').then_some(())
} else { } else {
let (punct, _) = cursor.punct()?; let (punct, _) = cursor.punct()?;
(punct.as_char() == '>').as_option() (punct.as_char() == '>').then_some(())
} }
} }
} }
@ -156,12 +157,16 @@ impl HtmlListClose {
impl PeekValue<()> for HtmlListClose { impl PeekValue<()> for HtmlListClose {
fn peek(cursor: Cursor) -> Option<()> { fn peek(cursor: Cursor) -> Option<()> {
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '<').as_option()?; if punct.as_char() != '<' {
return None;
}
let (punct, cursor) = cursor.punct()?; let (punct, cursor) = cursor.punct()?;
(punct.as_char() == '/').as_option()?; if punct.as_char() != '/' {
return None;
}
let (punct, _) = cursor.punct()?; let (punct, _) = cursor.punct()?;
(punct.as_char() == '>').as_option() (punct.as_char() == '>').then_some(())
} }
} }
impl Parse for HtmlListClose { impl Parse for HtmlListClose {

View File

@ -10,7 +10,6 @@ rust-version = "1.62"
yew-agent = { path = "../../packages/yew-agent/" } yew-agent = { path = "../../packages/yew-agent/" }
[dev-dependencies] [dev-dependencies]
boolinator = "2.4"
derive_more = "0.99" derive_more = "0.99"
gloo = "0.10" gloo = "0.10"
js-sys = "0.3" js-sys = "0.3"