mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +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();
|
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.
|
/// Inserts a delimiter at the given position.
|
||||||
pub fn insert_delimiter(&mut self, i: usize) {
|
pub fn insert_delimiter(&mut self, i: usize) {
|
||||||
self.children.insert(i, MenuItem::Delimiter);
|
self.children.insert(i, MenuItem::Delimiter);
|
||||||
@ -171,7 +166,7 @@ impl MenuTree {
|
|||||||
/// or if it wasn't a subtree.
|
/// or if it wasn't a subtree.
|
||||||
pub fn find_subtree(&mut self, title: &str) -> Option<&mut MenuTree> {
|
pub fn find_subtree(&mut self, title: &str) -> Option<&mut MenuTree> {
|
||||||
self.find_item(title).and_then(|item| {
|
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))
|
Some(Rc::make_mut(tree))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -191,4 +186,10 @@ impl MenuTree {
|
|||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.children.len()
|
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()
|
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 the item at the given position.
|
||||||
///
|
///
|
||||||
/// Returns `None` if `i > self.len()`
|
/// Returns `None` if `i > self.len()`
|
||||||
|
Loading…
Reference in New Issue
Block a user