diff --git a/src/views/select_view.rs b/src/views/select_view.rs index 2c6df29..9df0556 100644 --- a/src/views/select_view.rs +++ b/src/views/select_view.rs @@ -215,6 +215,19 @@ impl SelectView { self.items.push(Item::new(label.into(), value)); } + /// Gets an item at given idx or None. + /// + /// ``` + /// use cursive::Cursive; + /// use cursive::views::{SelectView, TextView}; + /// let select = SelectView::new() + /// .item("Short", 1); + /// assert_eq!(select.get_item(0), Some(("Short", &1))); + /// ``` + pub fn get_item(&self, i: usize) -> Option<(&str, &T)> { + self.items.get(i).map(|item| (item.label.as_ref(), &*item.value)) + } + /// Removes an item from the list. pub fn remove_item(&mut self, id: usize) { self.items.remove(id);