Add Menubar::is_empty(&self)

And fix another clippy warning
This commit is contained in:
Alexandre Bury 2017-01-27 14:51:46 -08:00
parent 1b5cb4a89a
commit 8b88bf9ba2
2 changed files with 12 additions and 6 deletions

View File

@ -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()
}
}

View File

@ -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()`