Repository: FGRibreau/spinners (language: rust)

Issue:
Function to add a symbol as well as text to the spinner
Currently, there are two functions, one for stopping the spinner with a symbol and one for stopping it with a text. However, it would be awesome if we could supply a custom symbol as well as custom text. Theoretically, I could supply the symbol along with the message but that means more code from the user's side.

We can also have functions like `succeed` and `fail` which will have a preset symbol like a green tick or red cross.

I will also try to make a pr for this


Discussion / hints:

Fix patch:
diff --git a/examples/stop_persist.rs b/examples/stop_persist.rs
new file mode 100644
index 0000000..09f16ee
--- /dev/null
+++ b/examples/stop_persist.rs
@@ -0,0 +1,14 @@
+use spinners::{Spinner, Spinners};
+use std::{env, str::FromStr, thread::sleep, time::Duration};
+
+fn main() {
+    let mut args = env::args();
+    let spinner_name = args.nth(1).unwrap_or_else(|| "Dots9".to_string());
+
+    let mut sp = Spinner::new(
+        Spinners::from_str(&spinner_name).unwrap(),
+        "Waiting for 3 seconds".into(),
+    );
+    sleep(Duration::from_secs(3));
+    sp.stop_and_persist("✔", "That worked!".to_string())
+}
diff --git a/src/lib.rs b/src/lib.rs
index a44aaac..05d07cb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -189,7 +189,25 @@ impl Spinner {
     /// ```
     pub fn stop_with_message(&mut self, msg: String) {
         self.stop();
-        print!("\r{}", msg);
+        println!("\x1b[2K\r{}", msg);
+    }
+
+    /// Stops the spinner with a provided symbol and message
+    ///
+    /// # Examples
+    ///
+    /// Basic Usage:
+    ///
+    /// ```
+    /// use spinners::{Spinner, Spinners};
+    ///
+    /// let mut sp = Spinner::new(Spinners::Dots, "Loading things into memory...".into());
+    ///
+    /// sp.stop_and_persist("✔", "Finished loading things into memory!".into());
+    /// ```
+    pub fn stop_and_persist(&mut self, symbol: &str, msg: String) {
+        self.stop();
+        println!("\x1b[2K\r{} {}", symbol, msg);
     }
 
     fn stop_inner(&mut self, stop_time: Instant, stop_symbol: Option<String>) {


Test patch: