From e8558b427a02819ece68796b296aac856a993cba Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:27:28 -0700 Subject: [PATCH] Fix clippy::type_complexity, refactor type alias Use a type alias to refactor the submit_funcs type definition, as a vector of boxed SubmitFuncs. Note this type alias isn't used in the parameterized add_submit_func() function because it accepts a trait, not a type - no `dyn` keyword in this context, but it is needed in the type definition. --- src/ui/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 15b4b09..43e1b4e 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1494,6 +1494,8 @@ impl Button { } } +type SubmitFunc = dyn Fn(&mut TextBox, &mut crate::Game); + element! { ref TextBoxRef pub struct TextBox { @@ -1505,7 +1507,7 @@ element! { priv text: Option, priv was_focused: bool, priv cursor_tick: f64, - priv submit_funcs: Vec>, + priv submit_funcs: Vec>, } builder TextBoxBuilder { hardcode button = None,