mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-08 18:30:40 +00:00
Add Menubar::is_empty(&self)
And fix another clippy warning
This commit is contained in:
parent
1b5cb4a89a
commit
8b88bf9ba2
13
src/menu.rs
13
src/menu.rs
@ -75,11 +75,6 @@ impl MenuTree {
|
||||
self.children.clear();
|
||||
}
|
||||
|
||||
/// Returns `true` if this tree has no children.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.children.is_empty()
|
||||
}
|
||||
|
||||
/// Inserts a delimiter at the given position.
|
||||
pub fn insert_delimiter(&mut self, i: usize) {
|
||||
self.children.insert(i, MenuItem::Delimiter);
|
||||
@ -171,7 +166,7 @@ impl MenuTree {
|
||||
/// or if it wasn't a subtree.
|
||||
pub fn find_subtree(&mut self, title: &str) -> Option<&mut MenuTree> {
|
||||
self.find_item(title).and_then(|item| {
|
||||
if let &mut MenuItem::Subtree(_, ref mut tree) = item {
|
||||
if let MenuItem::Subtree(_, ref mut tree) = *item {
|
||||
Some(Rc::make_mut(tree))
|
||||
} else {
|
||||
None
|
||||
@ -191,4 +186,10 @@ impl MenuTree {
|
||||
pub fn len(&self) -> usize {
|
||||
self.children.len()
|
||||
}
|
||||
|
||||
/// Returns `true` if this tree has no children.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.children.is_empty()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -99,6 +99,11 @@ impl Menubar {
|
||||
self.menus.len()
|
||||
}
|
||||
|
||||
/// Returns `true` if this menubar is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.menus.is_empty()
|
||||
}
|
||||
|
||||
/// Returns the item at the given position.
|
||||
///
|
||||
/// Returns `None` if `i > self.len()`
|
||||
|
Loading…
Reference in New Issue
Block a user