Skip to content

Commit

Permalink
Replace SelectView::focus with selected_id
Browse files Browse the repository at this point in the history
Returns None if the list is empty.
Also add `SelectView::len`
  • Loading branch information
gyscos committed Sep 1, 2016
1 parent 16dea39 commit 484f818
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/views/select_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 484f818

Please sign in to comment.