pub struct FuzzySelect<T> { /* private fields */ }
Expand description
A fuzzy select prompt. See the module level documentation for more information.
Implementations§
Source§impl<T> FuzzySelect<T>
impl<T> FuzzySelect<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/demo.rs (line 8)
5fn main() {
6 let items = vec!["Hello there", "General Kenobi", "You are a bold one"];
7
8 let item = FuzzySelect::new()
9 .with_prompt("Select your destiny:")
10 .with_options(items)
11 .with_query("o")
12 .with_initial_selection(2)
13 .select()
14 .expect("Failed to create FuzzySelect");
15
16 println!("You have chosen: {item:?}");
17}
Sourcepub fn with_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_prompt(self, prompt: impl Into<String>) -> Self
Examples found in repository?
examples/demo.rs (line 9)
5fn main() {
6 let items = vec!["Hello there", "General Kenobi", "You are a bold one"];
7
8 let item = FuzzySelect::new()
9 .with_prompt("Select your destiny:")
10 .with_options(items)
11 .with_query("o")
12 .with_initial_selection(2)
13 .select()
14 .expect("Failed to create FuzzySelect");
15
16 println!("You have chosen: {item:?}");
17}
pub fn without_prompt(self) -> Self
pub fn set_prompt<P: Into<String>>(self, prompt: impl Into<Option<P>>) -> Self
Sourcepub fn with_options(self, options: Vec<T>) -> Self
pub fn with_options(self, options: Vec<T>) -> Self
Examples found in repository?
examples/demo.rs (line 10)
5fn main() {
6 let items = vec!["Hello there", "General Kenobi", "You are a bold one"];
7
8 let item = FuzzySelect::new()
9 .with_prompt("Select your destiny:")
10 .with_options(items)
11 .with_query("o")
12 .with_initial_selection(2)
13 .select()
14 .expect("Failed to create FuzzySelect");
15
16 println!("You have chosen: {item:?}");
17}
pub fn with_options_from_iter( self, options: impl IntoIterator<Item = T>, ) -> Self
pub fn with_options_from_slice(self, options: &[T]) -> Selfwhere
T: Clone,
pub fn add_option(self, option: T) -> Self
pub fn add_options(self, options: impl IntoIterator<Item = T>) -> Self
Sourcepub fn with_initial_selection(self, initial_selection: u32) -> Self
pub fn with_initial_selection(self, initial_selection: u32) -> Self
Examples found in repository?
examples/demo.rs (line 12)
5fn main() {
6 let items = vec!["Hello there", "General Kenobi", "You are a bold one"];
7
8 let item = FuzzySelect::new()
9 .with_prompt("Select your destiny:")
10 .with_options(items)
11 .with_query("o")
12 .with_initial_selection(2)
13 .select()
14 .expect("Failed to create FuzzySelect");
15
16 println!("You have chosen: {item:?}");
17}
Sourcepub fn with_query(self, query: impl Into<String>) -> Self
pub fn with_query(self, query: impl Into<String>) -> Self
Examples found in repository?
examples/demo.rs (line 11)
5fn main() {
6 let items = vec!["Hello there", "General Kenobi", "You are a bold one"];
7
8 let item = FuzzySelect::new()
9 .with_prompt("Select your destiny:")
10 .with_options(items)
11 .with_query("o")
12 .with_initial_selection(2)
13 .select()
14 .expect("Failed to create FuzzySelect");
15
16 println!("You have chosen: {item:?}");
17}
pub fn without_query(self) -> Self
pub fn set_query<Q: Into<String>>(self, query: impl Into<Option<Q>>) -> Self
pub fn with_filter(self) -> Self
pub fn without_filter(self) -> Self
pub fn set_filter(self, filter: bool) -> Self
pub fn with_select1(self) -> Self
pub fn without_select1(self) -> Self
pub fn set_select1(self, select1: bool) -> Self
pub fn without_highlight(self) -> Self
pub fn set_highlight(self, highlight: bool) -> Self
pub fn with_page_size(self, page_size: u16) -> Self
pub fn with_default_page_size(self) -> Self
pub fn with_color(self, color: bool) -> Self
pub fn with_default_color(self) -> Self
pub fn set_color(self, color: impl Into<Option<bool>>) -> Self
pub fn with_theme(self, theme: Theme) -> Self
pub fn with_default_theme(self) -> Self
pub fn without_alternate_screen(self) -> Self
pub fn with_alternate_screen(self) -> Self
pub fn set_alternate_screen(self, alternate_screen: bool) -> Self
Sourcepub fn select(self) -> Result<T>where
T: Select,
pub fn select(self) -> Result<T>where
T: Select,
Runs the fuzzy select prompt and returns the selected item.
§Errors
Error::NoOptions
if there are no options to select from. Need to call one of the*option*
methods before calling this.Error::Cancelled
if the user cancelled the selection (e.g. by hitting Ctrl-C or Esc).Error::InvalidSelection
if the default selection index is out of bounds based off the provided options.Error::NonInteractive
if the terminal is not in interactive mode. This is the case if the terminal is not a tty.Error::IoError
if there was an error interacting with interacting with terminal in general.
Examples found in repository?
examples/demo.rs (line 13)
5fn main() {
6 let items = vec!["Hello there", "General Kenobi", "You are a bold one"];
7
8 let item = FuzzySelect::new()
9 .with_prompt("Select your destiny:")
10 .with_options(items)
11 .with_query("o")
12 .with_initial_selection(2)
13 .select()
14 .expect("Failed to create FuzzySelect");
15
16 println!("You have chosen: {item:?}");
17}
Sourcepub fn select_opt(self) -> Result<Option<T>>where
T: Select,
pub fn select_opt(self) -> Result<Option<T>>where
T: Select,
Runs the fuzzy select prompt and returns the selected item or None if no selection was made.
§Errors
Error::NonInteractive
if the terminal is not in interactive mode. This is the case if the terminal is not a tty.Error::IoError
if there was an error interacting with interacting with terminal in general.
Trait Implementations§
Source§impl<T: Clone> Clone for FuzzySelect<T>
impl<T: Clone> Clone for FuzzySelect<T>
Source§fn clone(&self) -> FuzzySelect<T>
fn clone(&self) -> FuzzySelect<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for FuzzySelect<T>
impl<T: Debug> Debug for FuzzySelect<T>
Auto Trait Implementations§
impl<T> Freeze for FuzzySelect<T>
impl<T> RefUnwindSafe for FuzzySelect<T>where
T: RefUnwindSafe,
impl<T> Send for FuzzySelect<T>where
T: Send,
impl<T> Sync for FuzzySelect<T>where
T: Sync,
impl<T> Unpin for FuzzySelect<T>where
T: Unpin,
impl<T> UnwindSafe for FuzzySelect<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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