Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
FGRibreau committed Mar 11, 2022
1 parent 2abbaf4 commit 3de8afa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/stop_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ fn main() {
);
sleep(Duration::from_secs(3));
sp.stop_with_symbol("\x1b[32m🗸\x1b[0m");
}
}
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use crate::utils::spinners_data::SPINNERS as SpinnersMap;
mod utils;

pub struct Spinner {
sender: Sender<(Instant, Option<String>)>,
join: JoinHandle<()>,
sender: Sender<(Instant, Option<String>)>
}

impl Drop for Spinner {
fn drop(&mut self) {
self.sender.send(()).unwrap();
self.sender.send((Instant::now(), None)).unwrap();
}
}

Expand Down Expand Up @@ -60,7 +59,7 @@ impl Spinner {

let (sender, recv) = channel::<(Instant, Option<String>)>();

let join = thread::spawn(move || 'outer: loop {
thread::spawn(move || 'outer: loop {
let mut stdout = stdout();
for frame in spinner_data.frames.iter() {
let (do_stop, stop_time, stop_symbol) = match recv.try_recv() {
Expand Down Expand Up @@ -92,7 +91,7 @@ impl Spinner {
}
});

Self {sender, join}
Self {sender}
}

// TODO: Add update message function
Expand Down Expand Up @@ -193,7 +192,6 @@ impl Spinner {
self.sender
.send((stop_time, stop_symbol))
.expect("Could not stop spinner thread.");
self.join.join().unwrap();
}
}

0 comments on commit 3de8afa

Please sign in to comment.