From fc52296d1205cf76dc93b0c132532ea0d4563187 Mon Sep 17 00:00:00 2001 From: JoeZane Date: Fri, 13 Jun 2025 01:14:55 +0800 Subject: [PATCH] upd: fix some clippy warn, add `get_view_size` func to SvgIcon. --- macros/src/stack.rs | 1 + tlib/src/actions.rs | 1 + tlib/src/types.rs | 4 ++-- tmui/src/icons/svg_icon.rs | 5 +++++ tmui/src/primitive/message.rs | 1 + tmui/src/tooltip.rs | 1 + tmui/src/views/list_view/list_store.rs | 2 +- tmui/src/views/tree_view/tree_store.rs | 2 +- 8 files changed, 13 insertions(+), 4 deletions(-) diff --git a/macros/src/stack.rs b/macros/src/stack.rs index 68568154..9bb7161b 100644 --- a/macros/src/stack.rs +++ b/macros/src/stack.rs @@ -35,6 +35,7 @@ pub(crate) fn generate_stack_remove_children() -> syn::Result, diff --git a/tlib/src/types.rs b/tlib/src/types.rs index b42cabc3..76715ae5 100644 --- a/tlib/src/types.rs +++ b/tlib/src/types.rs @@ -353,7 +353,7 @@ impl StaticType for String { fn dyn_bytes_len(&self) -> usize { // An extra '\0' - self.bytes().len() + 1 + self.len() + 1 } } @@ -368,7 +368,7 @@ impl StaticType for &str { fn dyn_bytes_len(&self) -> usize { // An extra '\0' - self.bytes().len() + 1 + self.len() + 1 } } diff --git a/tmui/src/icons/svg_icon.rs b/tmui/src/icons/svg_icon.rs index 804ac001..7436ffbf 100644 --- a/tmui/src/icons/svg_icon.rs +++ b/tmui/src/icons/svg_icon.rs @@ -75,6 +75,11 @@ impl SvgIcon { pub fn load_bytes(&mut self, data: &[u8]) { self.build_from_data(data); } + + #[inline] + pub fn get_view_size(&self) -> Size { + self.view_size + } } impl SvgIcon { diff --git a/tmui/src/primitive/message.rs b/tmui/src/primitive/message.rs index 5dadb6a7..3f8cf698 100644 --- a/tmui/src/primitive/message.rs +++ b/tmui/src/primitive/message.rs @@ -11,6 +11,7 @@ use tlib::{ winit::window::WindowId, }; +#[allow(clippy::large_enum_variant)] pub(crate) enum Message { /// VSync signal to redraw the window VSync(WindowId, Instant), diff --git a/tmui/src/tooltip.rs b/tmui/src/tooltip.rs index 79092d8a..1521c0e6 100644 --- a/tmui/src/tooltip.rs +++ b/tmui/src/tooltip.rs @@ -124,6 +124,7 @@ impl Tooltip { } } +#[allow(clippy::large_enum_variant)] pub(crate) enum TooltipStrat<'a> { Show(&'a str, Point, OptionSize, Option), Hide, diff --git a/tmui/src/views/list_view/list_store.rs b/tmui/src/views/list_view/list_store.rs index fc492dce..3e5b31b4 100644 --- a/tmui/src/views/list_view/list_store.rs +++ b/tmui/src/views/list_view/list_store.rs @@ -396,7 +396,7 @@ impl ListStore { /// @param `internal` /// - true: The view scrolling triggered internally in ListView - /// requires notifying the scroll bar to change the value. + /// requires notifying the scroll bar to change the value. /// /// @return `true` if scroll value has updated, should update the image. #[inline] diff --git a/tmui/src/views/tree_view/tree_store.rs b/tmui/src/views/tree_view/tree_store.rs index 63ab7b30..e8c4d397 100644 --- a/tmui/src/views/tree_view/tree_store.rs +++ b/tmui/src/views/tree_view/tree_store.rs @@ -557,7 +557,7 @@ impl TreeStore { /// @param `internal` /// - true: The view scrolling triggered internally in TreeView - /// requires notifying the scroll bar to change the value. + /// requires notifying the scroll bar to change the value. /// /// @return `true` if scroll value has updated, should update the image. #[inline]