From 0aceb02302313f4e39041f1b004b98a6b27492f9 Mon Sep 17 00:00:00 2001 From: stayhydated <56778463+stayhydated@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:08:42 -0400 Subject: [PATCH] dropdown: Replace specialized impl From Vec to Vec (#935) Needed for a proc macro i plan to publish when ready ```rs #[derive(Clone, DropdownItemFtl, EsFluent, EnumIter, EnumString)] #[fluent(enumerable)] pub enum PreferedLanguage { English, French, Chinese, } #[derive(Clone, DropdownItemFtl, EsFluent, EnumIter, EnumString)] #[fluent(enumerable)] pub enum Country { UnitedStates, France, China, } #[derive(GpuiForm)] pub struct User { #[gpui_form(component(input))] pub username: Option, #[gpui_form(component(input))] pub email: String, #[gpui_form(component(number_input))] pub age: Option, #[gpui_form(component(number_input))] pub balance: Decimal, #[gpui_form(component(check_box))] pub subscribe_newsletter: bool, #[gpui_form(component(switch))] pub enable_notifications: bool, #[gpui_form(component(dropdown(searchable)))] pub country: Option, #[gpui_form(component(dropdown()))] pub preferred_language: PreferedLanguage, #[gpui_form(component(calendar))] pub birth_date: chrono::NaiveDate, #[gpui_form(component(date_picker))] pub appointment_date: chrono::NaiveDate, #[gpui_form(component(progress))] pub completion_percentage: f32, #[gpui_form(skip)] pub skip_me: bool, } ``` --- crates/ui/src/dropdown.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/ui/src/dropdown.rs b/crates/ui/src/dropdown.rs index 1293fcc4..ec368cf4 100644 --- a/crates/ui/src/dropdown.rs +++ b/crates/ui/src/dropdown.rs @@ -281,6 +281,15 @@ impl SearchableVec { } } +impl From> for SearchableVec { + fn from(items: Vec) -> Self { + Self { + items: items.clone(), + matched_items: items, + } + } +} + impl DropdownDelegate for SearchableVec { type Item = T; @@ -322,15 +331,6 @@ impl DropdownDelegate for SearchableVec { } } -impl From> for SearchableVec { - fn from(items: Vec) -> Self { - Self { - items: items.clone(), - matched_items: items, - } - } -} - impl DropdownState where D: DropdownDelegate + 'static,