[][src]Struct termprompt::Sort

pub struct Sort<'a> { /* fields omitted */ }

Renders a sort prompt.

Returns list of indices in original items list sorted according to user input.

Example usage

use dialoguer::Sort;

let items_to_order = vec!["Item 1", "Item 2", "Item 3"];
let ordered = Sort::new()
    .with_prompt("Order the items")
    .items(&items_to_order)
    .interact()?;

Implementations

impl<'a> Sort<'a>[src]

pub fn new() -> Sort<'static>[src]

Creates a sort prompt.

pub fn with_theme(theme: &'a dyn Theme) -> Sort<'a>[src]

Creates a sort prompt with a specific theme.

pub fn paged(&mut self, val: bool) -> &mut Sort<'a>[src]

Enables or disables paging

pub fn clear(&mut self, val: bool) -> &mut Sort<'a>[src]

Sets the clear behavior of the menu.

The default is to clear the menu after user interaction.

pub fn item<T: ToString>(&mut self, item: T) -> &mut Sort<'a>[src]

Add a single item to the selector.

pub fn items<T: ToString>(&mut self, items: &[T]) -> &mut Sort<'a>[src]

Adds multiple items to the selector.

pub fn with_prompt<S: Into<String>>(&mut self, prompt: S) -> &mut Sort<'a>[src]

Prefaces the menu with a prompt.

When a prompt is set the system also prints out a confirmation after the selection.

pub fn interact(&self) -> Result<Vec<usize>>[src]

Enables user interaction and returns the result.

The user can order the items with the space bar and the arrows. On enter the ordered list will be returned.

pub fn interact_on(&self, term: &Term) -> Result<Vec<usize>>[src]

Like interact but allows a specific terminal to be set.

Trait Implementations

impl<'a> Default for Sort<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Sort<'a>

impl<'a> !Send for Sort<'a>

impl<'a> !Sync for Sort<'a>

impl<'a> Unpin for Sort<'a>

impl<'a> !UnwindSafe for Sort<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,