From 85f3c0186cb46476a083d3750f8e097b8e721db9 Mon Sep 17 00:00:00 2001 From: jewlexx Date: Fri, 25 Feb 2022 17:58:47 +1100 Subject: [PATCH] added stop on drop --- Cargo.toml | 2 +- src/lib.rs | 6 ++++++ src/utils/mod.rs | 2 +- src/utils/spinner_data.rs | 1 - 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 779b900..9accd4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,4 @@ include = ["src/**/*", "README.md"] [dependencies] lazy_static = { version = "1.4.0" } maplit = { version = "1.0.2" } -strum = { version = "0.23.0", features = ["derive"] } +strum = { version = "0.24.0", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs index 5888fe0..b5e7e0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,12 @@ pub struct Spinner { sender: Sender<()>, } +impl Drop for Spinner { + fn drop(&mut self) { + self.sender.send(()).unwrap(); + } +} + impl Spinner { /// Create a new spinner along with a message /// diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3466ad5..759a102 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,3 +1,3 @@ +pub mod spinner_data; pub mod spinner_names; pub mod spinners_data; -pub mod spinner_data; diff --git a/src/utils/spinner_data.rs b/src/utils/spinner_data.rs index 43b2f27..fb3b424 100644 --- a/src/utils/spinner_data.rs +++ b/src/utils/spinner_data.rs @@ -3,4 +3,3 @@ pub struct SpinnerData { pub frames: Vec<&'static str>, pub interval: u16, } -