From 3701c85ffdfea9cdb74ab78e16a83850ac13d0b1 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 5 Sep 2016 15:33:52 -0700 Subject: [PATCH] Add `clear` methods to `SelectView` and `ListView` --- src/views/list_view.rs | 5 +++++ src/views/select_view.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/views/list_view.rs b/src/views/list_view.rs index cf53921..e51a57c 100644 --- a/src/views/list_view.rs +++ b/src/views/list_view.rs @@ -64,6 +64,11 @@ impl ListView { self.children.push(Child::Row(label.to_string(), Box::new(view))); } + /// Removes all children from this view. + pub fn clear(&mut self) { + self.children.clear(); + } + /// Adds a view to the end of the list. /// /// Chainable variant. diff --git a/src/views/select_view.rs b/src/views/select_view.rs index 99d70ed..29cbab1 100644 --- a/src/views/select_view.rs +++ b/src/views/select_view.rs @@ -190,6 +190,11 @@ impl SelectView { self.items[self.focus()].value.clone() } + /// Removes all items from this view. + pub fn clear(&mut self) { + self.items.clear(); + } + /// Adds a item to the list, with given label and value. pub fn add_item>(&mut self, label: S, value: T) { self.items.push(Item::new(label.into(), value));