diff --git a/demo/src/pages/nav_bar/mod.rs b/demo/src/pages/nav_bar/mod.rs
index 9d159885..79709a72 100644
--- a/demo/src/pages/nav_bar/mod.rs
+++ b/demo/src/pages/nav_bar/mod.rs
@@ -4,7 +4,6 @@ use leptos::*;
use thaw::mobile::{NavBar, NavBarRight};
use thaw::Icon;
-
#[component]
pub fn NavBarPage() -> impl IntoView {
view! {
diff --git a/demo_markdown/docs/drawer/mod.md b/demo_markdown/docs/drawer/mod.md
index 234fd4e9..01d2c34b 100644
--- a/demo_markdown/docs/drawer/mod.md
+++ b/demo_markdown/docs/drawer/mod.md
@@ -13,10 +13,10 @@ let open = Callback::new(move |new_placement: DrawerPlacement| {
view! {
-
-
-
-
+
+
+
+
"Hello"
diff --git a/demo_markdown/src/lib.rs b/demo_markdown/src/lib.rs
index 30e7bd72..e5322c7e 100644
--- a/demo_markdown/src/lib.rs
+++ b/demo_markdown/src/lib.rs
@@ -96,7 +96,7 @@ pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenSt
links
);
syn::parse_str::(&toc)
- .expect(&format!("Cannot be resolved as a function: \n {toc}"))
+ .unwrap_or_else(|_| panic!("Cannot be resolved as a function: \n {toc}"))
};
let demos: Vec = demos
diff --git a/demo_markdown/src/markdown/code_block.rs b/demo_markdown/src/markdown/code_block.rs
index 92afdab7..6f3db637 100644
--- a/demo_markdown/src/markdown/code_block.rs
+++ b/demo_markdown/src/markdown/code_block.rs
@@ -18,8 +18,7 @@ pub fn to_tokens(code_block: &NodeCodeBlock, demos: &mut Vec) -> TokenSt
let literal = langs
.iter()
.find(|lang| lang != &&"demo")
- .map(|lang| highlight_to_html(&code_block.literal, lang))
- .flatten()
+ .and_then(|lang| highlight_to_html(&code_block.literal, lang))
.unwrap_or_else(|| {
is_highlight = false;
code_block.literal.clone()
@@ -37,8 +36,7 @@ pub fn to_tokens(code_block: &NodeCodeBlock, demos: &mut Vec) -> TokenSt
let mut is_highlight = true;
let literal = langs
.first()
- .map(|lang| highlight_to_html(&code_block.literal, lang))
- .flatten()
+ .and_then(|lang| highlight_to_html(&code_block.literal, lang))
.unwrap_or_else(|| {
is_highlight = false;
code_block.literal.clone()
@@ -56,10 +54,8 @@ pub fn to_tokens(code_block: &NodeCodeBlock, demos: &mut Vec) -> TokenSt
static SYNTAX_SET: OnceLock = OnceLock::new();
fn highlight_to_html(text: &str, syntax: &str) -> Option {
- let syntax_set = SYNTAX_SET.get_or_init(|| SyntaxSet::load_defaults_newlines());
- let Some(syntax) = syntax_set.find_syntax_by_token(syntax) else {
- return None;
- };
+ let syntax_set = SYNTAX_SET.get_or_init(SyntaxSet::load_defaults_newlines);
+ let syntax = syntax_set.find_syntax_by_token(syntax)?;
let mut html_generator = ClassedHTMLGenerator::new_with_class_style(
syntax,
diff --git a/demo_markdown/src/markdown/mod.rs b/demo_markdown/src/markdown/mod.rs
index 95f8d0da..30febb63 100644
--- a/demo_markdown/src/markdown/mod.rs
+++ b/demo_markdown/src/markdown/mod.rs
@@ -8,7 +8,10 @@ use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::ItemMacro;
-pub fn parse_markdown(md_text: &str) -> Result<(TokenStream, Vec, Vec<(String, String)>), String> {
+#[allow(clippy::type_complexity)]
+pub fn parse_markdown(
+ md_text: &str,
+) -> Result<(TokenStream, Vec, Vec<(String, String)>), String> {
let mut demos: Vec = vec![];
let mut toc: Vec<(String, String)> = vec![];
@@ -16,7 +19,7 @@ pub fn parse_markdown(md_text: &str) -> Result<(TokenStream, Vec, Vec<(S
let mut options = comrak::Options::default();
options.extension.table = true;
- let root = parse_document(&arena, &md_text, &options);
+ let root = parse_document(&arena, md_text, &options);
let body = iter_nodes(md_text, root, &mut demos, &mut toc);
Ok((body, demos, toc))
}
@@ -45,10 +48,12 @@ fn iter_nodes<'a>(
NodeValue::HtmlBlock(node_html_block) => {
let html =
syn::parse_str::(&format!("view! {{ {} }}", node_html_block.literal))
- .expect(&format!(
- "Cannot be resolved as a macro: \n {}",
- node_html_block.literal
- ));
+ .unwrap_or_else(|_| {
+ panic!(
+ "Cannot be resolved as a macro: \n {}",
+ node_html_block.literal
+ )
+ });
quote!(
{
#html
@@ -62,10 +67,10 @@ fn iter_nodes<'a>(
),
NodeValue::Heading(node_h) => {
let sourcepos = node.data.borrow().sourcepos;
- let text = range_text(md_text, sourcepos.start.clone(), sourcepos.end.clone());
+ let text = range_text(md_text, sourcepos.start, sourcepos.end);
let level = node_h.level as usize + 1;
let text = text[level..].to_string();
- let h_id = format!("{}", text.replace(' ', "-").to_ascii_lowercase());
+ let h_id = text.replace(' ', "-").to_ascii_lowercase().to_string();
toc.push((h_id.clone(), text));
let h = Ident::new(&format!("h{}", node_h.level), Span::call_site());
quote!(
@@ -186,7 +191,7 @@ fn range_text(text: &str, start: LineColumn, end: LineColumn) -> &str {
let mut current_line_num = start_line + 1;
while current_line_num < end_line {
let next_line = lines.next().unwrap_or("");
- start_line_text = &next_line;
+ start_line_text = next_line;
current_line_num += 1;
}
diff --git a/thaw/src/back_top/mod.rs b/thaw/src/back_top/mod.rs
index 639b8800..e2e22c6b 100644
--- a/thaw/src/back_top/mod.rs
+++ b/thaw/src/back_top/mod.rs
@@ -6,7 +6,8 @@ use crate::{use_theme, Icon, Theme};
use leptos::{html::ToHtmlElement, *};
use thaw_components::{CSSTransition, Fallback, OptionComp, Teleport};
use thaw_utils::{
- add_event_listener, class_list, get_scroll_parent, mount_style, EventListenerHandle, OptionalProp,
+ add_event_listener, class_list, get_scroll_parent, mount_style, EventListenerHandle,
+ OptionalProp,
};
#[component]
diff --git a/thaw/src/back_top/theme.rs b/thaw/src/back_top/theme.rs
index 10cec496..d8e7ebb7 100644
--- a/thaw/src/back_top/theme.rs
+++ b/thaw/src/back_top/theme.rs
@@ -3,7 +3,6 @@ use crate::theme::ThemeMethod;
#[derive(Clone)]
pub struct BackTopTheme {
pub background_color: String,
-
}
impl ThemeMethod for BackTopTheme {
diff --git a/thaw_utils/src/class_list.rs b/thaw_utils/src/class_list.rs
index 567beacc..8ed7894d 100644
--- a/thaw_utils/src/class_list.rs
+++ b/thaw_utils/src/class_list.rs
@@ -5,6 +5,12 @@ use std::{collections::HashSet, rc::Rc};
pub struct ClassList(RwSignal>>);
+impl Default for ClassList {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl ClassList {
pub fn new() -> Self {
Self(RwSignal::new(HashSet::new()))
diff --git a/thaw_utils/src/dom/get_scroll_parent.rs b/thaw_utils/src/dom/get_scroll_parent.rs
index 29dd9d61..16dfc9ed 100644
--- a/thaw_utils/src/dom/get_scroll_parent.rs
+++ b/thaw_utils/src/dom/get_scroll_parent.rs
@@ -4,9 +4,7 @@ use leptos::{
};
pub fn get_scroll_parent(element: &HtmlElement) -> Option> {
- let Some(parent_element) = get_parent_element(element) else {
- return None;
- };
+ let parent_element = get_parent_element(element)?;
if parent_element.node_type() == 9 {
return Some(parent_element);
diff --git a/thaw_utils/src/hooks/use_click_position.rs b/thaw_utils/src/hooks/use_click_position.rs
index 49df5977..d2aeec2e 100644
--- a/thaw_utils/src/hooks/use_click_position.rs
+++ b/thaw_utils/src/hooks/use_click_position.rs
@@ -12,9 +12,7 @@ pub fn use_click_position() -> ReadSignal