Lazy_load: move to utils module and make it public.

This commit is contained in:
Jordan Petridis
2018-04-10 16:57:08 +00:00
committed by Merge Bot, Bors Wannabe
parent 4b4f5c39d4
commit 29cf5940f5
2 changed files with 19 additions and 19 deletions
+1 -19
View File
@@ -14,6 +14,7 @@ use hammond_data::utils::get_download_folder;
use app::Action;
use manager;
use utils::lazy_load;
use widgets::episode_states::*;
use std::cell::RefCell;
@@ -392,22 +393,3 @@ pub fn episodes_listbox(pd: Arc<Podcast>, sender: Sender<Action>) -> Result<gtk:
Ok(list)
}
use gtk::{IsA, Widget};
fn lazy_load<T, C, F, W>(data: T, container: C, mut contructor: F)
where
T: IntoIterator + 'static,
T::Item: 'static,
C: ContainerExt + 'static,
F: FnMut(T::Item) -> W + 'static,
W: IsA<Widget>,
{
let mut data = data.into_iter();
gtk::idle_add(move || {
data.next()
.map(|x| container.add(&contructor(x)))
.map(|_| glib::Continue(true))
.unwrap_or(glib::Continue(false))
});
}