mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Use intermediate type for the callback promise
Using actual promises would still be better
This commit is contained in:
parent
c1c9322319
commit
5e6222bf23
@ -7,15 +7,19 @@ use event::*;
|
||||
use theme::ColorStyle;
|
||||
use view::View;
|
||||
|
||||
pub type CbPromise = Option<Box<Fn(&mut Cursive) + Send>>;
|
||||
|
||||
/// Display progress.
|
||||
pub struct ProgressBar {
|
||||
min: usize,
|
||||
max: usize,
|
||||
value: Arc<AtomicUsize>,
|
||||
// TODO: use a Promise instead?
|
||||
callback: Option<Arc<Mutex<Option<Box<Fn(&mut Cursive) + Send>>>>>,
|
||||
callback: Option<Arc<Mutex<CbPromise>>>,
|
||||
}
|
||||
|
||||
new_default!(ProgressBar);
|
||||
|
||||
impl ProgressBar {
|
||||
/// Creates a new progress bar.
|
||||
///
|
||||
@ -43,7 +47,7 @@ impl ProgressBar {
|
||||
///
|
||||
/// Whenever `callback` is set, it will be called on the next event loop.
|
||||
pub fn with_callback(mut self,
|
||||
callback: Arc<Mutex<Option<Box<Fn(&mut Cursive) + Send>>>>)
|
||||
callback: Arc<Mutex<CbPromise>>)
|
||||
-> Self {
|
||||
self.callback = Some(callback);
|
||||
self
|
||||
|
Loading…
Reference in New Issue
Block a user