Replace SelectView::focus with selected_id

Returns None if the list is empty.
Also add `SelectView::len`
This commit is contained in:
Alexandre Bury 2016-08-31 17:05:58 -07:00
parent 16dea393c9
commit 484f81861a

View File

@ -240,7 +240,22 @@ impl<T: 'static> SelectView<T> {
}
/// Returns the id of the item currently selected.
pub fn focus(&self) -> usize {
///
/// Returns `None` if the list is empty.
pub fn selected_id(&self) -> Option<usize> {
if self.items.is_empty() {
None
} else {
Some(self.focus())
}
}
/// Returns the number of items in this list.
pub fn len(&self) -> usize {
self.items.len()
}
fn focus(&self) -> usize {
self.focus.get()
}