pub struct InputList { /* private fields */ }
Expand description

A struct that holds inputs available for the user to scroll through.

Implementations§

source§

impl InputList

source

pub fn new(maxlen: usize) -> Self

Make a new InputList with a certain maximum capacity.

Example
use term_basics_linux as tbl;
let mut his = tbl::InputList::new(10);
let x = tbl::input_field_scrollable(&mut his, true);
source

pub fn add(&mut self, string: &str)

Adds an element to the list. It will delete items if it’s length would grow past the max length. the oldest items will be removed.

Example
use term_basics_linux as tbl;
let mut his = tbl::InputList::new(2);
his.add(&"0".to_string());
his.add(&"1".to_string());
his.add(&"2".to_string());
// only "1" and "2" will remain, as 0 is removed.
let _ = tbl::input_field_scrollable(&mut his, true);
source

pub fn get_index(&self, index: i32) -> Option<&String>

Returns the an Option of String, the element at the given index. The index wraps and you can query for negative indices as well as indices above the maximum length.

Example
use term_basics_linux as tbl;
let mut his = tbl::InputList::new(3);
his.add(&"0".to_string());
his.add(&"1".to_string());
his.add(&"2".to_string());
println!("at -2: {:?}", his.get_index(-2)); // "1"
println!("at -1: {:?}", his.get_index(-1)); // "2"
println!("at  0: {:?}", his.get_index(0));  // "0"
println!("at  1: {:?}", his.get_index(1));  // "1"
println!("at  2: {:?}", his.get_index(2));  // "2"
println!("at  3: {:?}", his.get_index(3));  // "0"
println!("at  4: {:?}", his.get_index(4));  // "1"

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.