android: fix crash on mobile
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -158,13 +158,19 @@ impl Columns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn selected(&self) -> &Column {
|
pub fn selected(&self) -> Option<&Column> {
|
||||||
&self.columns[self.selected as usize]
|
if self.columns.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(&self.columns[self.selected as usize])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn selected_mut(&mut self) -> &mut Column {
|
pub fn selected_mut(&mut self) -> Option<&mut Column> {
|
||||||
&mut self.columns[self.selected as usize]
|
if self.columns.is_empty() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(&mut self.columns[self.selected as usize])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ impl DecksCache {
|
|||||||
/// Gets the first column in the currently active user's active deck
|
/// Gets the first column in the currently active user's active deck
|
||||||
pub fn selected_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
pub fn selected_column_mut(&mut self, accounts: ¬edeck::Accounts) -> Option<&mut Column> {
|
||||||
self.active_columns_mut(accounts)
|
self.active_columns_mut(accounts)
|
||||||
.map(|ad| ad.selected_mut())
|
.and_then(|ad| ad.selected_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn selected_column(&self, accounts: ¬edeck::Accounts) -> Option<&Column> {
|
pub fn selected_column(&self, accounts: ¬edeck::Accounts) -> Option<&Column> {
|
||||||
self.active_columns(accounts).map(|ad| ad.selected())
|
self.active_columns(accounts).and_then(|ad| ad.selected())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a mutable reference to the active columns
|
/// Gets a mutable reference to the active columns
|
||||||
|
|||||||
Reference in New Issue
Block a user