Skip to content

Commit

Permalink
configure rustfmt to reorg imports; run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-laplante authored and djc committed May 11, 2022
1 parent 3e8a805 commit 3ed096a
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 37 deletions.
10 changes: 6 additions & 4 deletions examples/multi-tree-ext.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use console::style;
use indicatif::{MultiProgress, MultiProgressAlignment, ProgressBar, ProgressStyle};
use once_cell::sync::Lazy;
use rand::{rngs::ThreadRng, Rng, RngCore};
use std::fmt::Debug;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;

use console::style;
use indicatif::{MultiProgress, MultiProgressAlignment, ProgressBar, ProgressStyle};
use once_cell::sync::Lazy;
use rand::rngs::ThreadRng;
use rand::{Rng, RngCore};
use structopt::StructOpt;

#[derive(Debug, Clone)]
Expand Down
8 changes: 5 additions & 3 deletions examples/multi-tree.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use once_cell::sync::Lazy;
use rand::{rngs::ThreadRng, Rng, RngCore};
use std::fmt::Debug;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;

use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use once_cell::sync::Lazy;
use rand::rngs::ThreadRng;
use rand::{Rng, RngCore};

#[derive(Debug, Clone)]
enum Action {
AddProgressBar(usize),
Expand Down
3 changes: 2 additions & 1 deletion examples/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use indicatif::ProgressBar;
use std::time::Duration;

use indicatif::ProgressBar;
use tokio::runtime;
use tokio::time::interval;

Expand Down
4 changes: 2 additions & 2 deletions examples/yarnish.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use rand::seq::SliceRandom;
use rand::Rng;
use std::thread;
use std::time::{Duration, Instant};

use console::{style, Emoji};
use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressStyle};
use rand::seq::SliceRandom;
use rand::Rng;

static PACKAGES: &[&str] = &[
"fs-events",
Expand Down
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports_granularity = "Module"
group_imports = "StdExternalCrate"
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ pub use crate::in_memory::InMemoryTerm;
pub use crate::iter::{ProgressBarIter, ProgressIterator};
pub use crate::multi::{MultiProgress, MultiProgressAlignment};
pub use crate::progress_bar::{ProgressBar, WeakProgressBar};
#[cfg(feature = "rayon")]
pub use crate::rayon::ParallelProgressIterator;
pub use crate::state::{ProgressFinish, ProgressState};
pub use crate::style::ProgressStyle;
pub use crate::term_like::TermLike;

#[cfg(feature = "rayon")]
pub use crate::rayon::ParallelProgressIterator;
16 changes: 7 additions & 9 deletions src/progress_bar.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
use std::borrow::Cow;
use std::sync::{Arc, Mutex, Weak};
use std::sync::{Condvar, MutexGuard};
#[cfg(test)]
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Condvar, Mutex, MutexGuard, Weak};
use std::time::{Duration, Instant};
use std::{fmt, mem};
use std::{io, thread};
use std::{fmt, io, mem, thread};

#[cfg(test)]
use once_cell::sync::Lazy;
#[cfg(test)]
use std::sync::atomic::{AtomicBool, Ordering};

use crate::draw_target::ProgressDrawTarget;
use crate::state::{AtomicPosition, BarState, ProgressFinish, Reset};
use crate::style::ProgressStyle;
use crate::ProgressState;
use crate::{ProgressBarIter, ProgressIterator};
use crate::{ProgressBarIter, ProgressIterator, ProgressState};

/// A progress bar or spinner
///
Expand Down Expand Up @@ -605,7 +602,8 @@ impl TickerControl {

// Wait for `interval` but return early if we are notified to stop
let (_, result) = self
.stopping.1
.stopping
.1
.wait_timeout_while(self.stopping.0.lock().unwrap(), interval, |stopped| {
!*stopped
})
Expand Down
14 changes: 7 additions & 7 deletions src/rayon.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{ProgressBar, ProgressBarIter};
use rayon::iter::{
plumbing::{Consumer, Folder, Producer, ProducerCallback, UnindexedConsumer},
IndexedParallelIterator, ParallelIterator,
};
use std::convert::TryFrom;

use rayon::iter::plumbing::{Consumer, Folder, Producer, ProducerCallback, UnindexedConsumer};
use rayon::iter::{IndexedParallelIterator, ParallelIterator};

use crate::{ProgressBar, ProgressBarIter};

/// Wraps a Rayon parallel iterator.
///
/// See [`ProgressIterator`](trait.ProgressIterator.html) for method
Expand Down Expand Up @@ -210,10 +210,10 @@ impl<S: Send, T: ParallelIterator<Item = S>> ParallelIterator for ProgressBarIte

#[cfg(test)]
mod test {
use crate::ProgressStyle;
use crate::{ParallelProgressIterator, ProgressBar, ProgressBarIter};
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};

use crate::{ParallelProgressIterator, ProgressBar, ProgressBarIter, ProgressStyle};

#[test]
fn it_can_wrap_a_parallel_iterator() {
let v = vec![1, 2, 3];
Expand Down
6 changes: 2 additions & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::borrow::Cow;
use std::fmt;
use std::io;
use std::sync::atomic::{AtomicU64, AtomicU8, Ordering};
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::{fmt, io};

use crate::draw_target::ProgressDrawTarget;
use crate::style::ProgressStyle;
Expand Down Expand Up @@ -484,9 +483,8 @@ pub(crate) enum Status {

#[cfg(test)]
mod tests {
use crate::ProgressBar;

use super::*;
use crate::ProgressBar;

#[test]
fn test_time_per_step() {
Expand Down
3 changes: 2 additions & 1 deletion src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,10 @@ enum Alignment {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use super::*;
use crate::state::{AtomicPosition, ProgressState};
use std::sync::Arc;

#[test]
fn test_expand_template() {
Expand Down
3 changes: 2 additions & 1 deletion src/term_like.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use console::Term;
use std::fmt::Debug;
use std::io;

use console::Term;

/// A trait for minimal terminal-like behavior.
///
/// Anything that implements this trait can be used a draw target via [`ProgressDrawTarget::term_like`].
Expand Down
3 changes: 2 additions & 1 deletion tests/multi-autodrop.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use indicatif::{MultiProgress, ProgressBar};
use std::thread;
use std::time::Duration;

use indicatif::{MultiProgress, ProgressBar};

#[test]
fn main() {
let pb = {
Expand Down
3 changes: 2 additions & 1 deletion tests/render.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#![cfg(feature = "in_memory")]

use std::time::Duration;

use indicatif::{
InMemoryTerm, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressFinish, ProgressStyle,
TermLike,
};
use std::time::Duration;

#[test]
fn basic_progress_bar() {
Expand Down

0 comments on commit 3ed096a

Please sign in to comment.