From ae58ddce2d6e6b37110cc9405a38eec090ea0716 Mon Sep 17 00:00:00 2001 From: Sam Tay Date: Sun, 12 Jul 2020 12:03:35 -0700 Subject: Run rustfmt --- src/term.rs | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/term.rs b/src/term.rs index 77f5457..86c0f4c 100644 --- a/src/term.rs +++ b/src/term.rs @@ -7,7 +7,7 @@ use std::io::{stderr, Write}; use termimad::{CompoundStyle, MadSkin}; use tokio::sync::{ oneshot, - oneshot::{error::TryRecvError, Sender, Receiver}, + oneshot::{error::TryRecvError, Receiver, Sender}, }; use tokio::task::JoinHandle; use tokio::time; @@ -34,7 +34,7 @@ impl Default for Term { struct Spinner { tx: Sender<()>, - handle: JoinHandle> + handle: JoinHandle>, } impl Term { @@ -123,7 +123,7 @@ impl Spinner { pub fn new() -> Self { let (tx, rx) = oneshot::channel(); let handle = tokio::spawn(Self::spin(rx)); - Spinner {tx, handle} + Spinner { tx, handle } } /// Stop the spinner. This requires a bit of cleanup, and so should be `await`ed before doing @@ -136,32 +136,32 @@ impl Spinner { /// Spin until receiver finds unit async fn spin(mut rx: Receiver<()>) -> Result<()> { - let mut dots = LOADING_SPINNER_DOTS.iter().cycle(); - terminal::enable_raw_mode()?; - execute!( - stderr(), - cursor::SavePosition, - cursor::Hide, - terminal::Clear(ClearType::CurrentLine), - )?; - let mut interval = time::interval(time::Duration::from_millis(LOADING_SPINNER_DELAY)); - while let Err(TryRecvError::Empty) = rx.try_recv() { - execute!( - stderr(), - cursor::MoveToColumn(0), - terminal::Clear(ClearType::CurrentLine), - Print(dots.next().unwrap()) - )?; - interval.tick().await; - } + let mut dots = LOADING_SPINNER_DOTS.iter().cycle(); + terminal::enable_raw_mode()?; + execute!( + stderr(), + cursor::SavePosition, + cursor::Hide, + terminal::Clear(ClearType::CurrentLine), + )?; + let mut interval = time::interval(time::Duration::from_millis(LOADING_SPINNER_DELAY)); + while let Err(TryRecvError::Empty) = rx.try_recv() { execute!( stderr(), + cursor::MoveToColumn(0), terminal::Clear(ClearType::CurrentLine), - cursor::RestorePosition, - cursor::Show, + Print(dots.next().unwrap()) )?; - terminal::disable_raw_mode()?; - Ok(()) + interval.tick().await; + } + execute!( + stderr(), + terminal::Clear(ClearType::CurrentLine), + cursor::RestorePosition, + cursor::Show, + )?; + terminal::disable_raw_mode()?; + Ok(()) } } -- cgit v1.2.3