pub struct OptionList { /* private fields */ }Expand description
A filterable, navigable list of option labels rendered as an inline dropdown.
Implementations§
Source§impl OptionList
impl OptionList
Sourcepub fn new(items: Vec<String>) -> OptionList
pub fn new(items: Vec<String>) -> OptionList
Builds a list over items, initially closed with every item matching.
Sourcepub fn open(&mut self)
pub fn open(&mut self)
Requests the dropdown be shown. Visibility is still gated on there being
at least one match (see is_open).
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Whether the dropdown is currently visible (open with at least one match).
Sourcepub fn refilter(&mut self, query: &str)
pub fn refilter(&mut self, query: &str)
Recomputes the matches for query (case-insensitive substring), resets
the cursor to the top, and clears the active flag so typing re-suggests
rather than committing to a highlighted row.
Sourcepub fn selected(&self) -> Option<&str>
pub fn selected(&self) -> Option<&str>
The highlighted label, but only once the user has engaged the list with
↑/↓ — so a type-ahead field can tell “accept this suggestion” apart from
“submit my typed text”.
Sourcepub fn set_cursor(&mut self, index: usize)
pub fn set_cursor(&mut self, index: usize)
Points the cursor at the match at index (clamped) and marks the list
active, used to seed a fixed-choice picker to its current value.
Sourcepub fn match_count(&self) -> usize
pub fn match_count(&self) -> usize
The number of matches (for rendering windowing / “N more” hints).
Sourcepub fn match_labels(&self) -> impl Iterator<Item = &str>
pub fn match_labels(&self) -> impl Iterator<Item = &str>
The match labels in display order (for rendering).
Trait Implementations§
Source§impl Clone for OptionList
impl Clone for OptionList
Source§fn clone(&self) -> OptionList
fn clone(&self) -> OptionList
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OptionList
impl Debug for OptionList
Source§impl Default for OptionList
impl Default for OptionList
Source§fn default() -> OptionList
fn default() -> OptionList
impl Eq for OptionList
Source§impl PartialEq for OptionList
impl PartialEq for OptionList
Source§fn eq(&self, other: &OptionList) -> bool
fn eq(&self, other: &OptionList) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for OptionList
Auto Trait Implementations§
impl Freeze for OptionList
impl RefUnwindSafe for OptionList
impl Send for OptionList
impl Sync for OptionList
impl Unpin for OptionList
impl UnsafeUnpin for OptionList
impl UnwindSafe for OptionList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more