Struct progression::Bar

source ·
pub struct Bar<'a> { /* private fields */ }

Implementations§

source§

impl<'a> Bar<'a>

source

pub fn new(len: u64, config: Config<'a>) -> Self

Examples found in repository?
examples/example.rs (line 31)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
fn main() {
	// Default
	for _ in progression::bar(0..1_000) {
		thread::sleep(Duration::from_millis(1));
	}

	// Cargo style
	for _ in progression::bar_with_config(0..1_000, progression::Config::cargo()) {
		thread::sleep(Duration::from_millis(1));
	}

	// Unicode style
	for _ in progression::bar_with_config(0..1_000, progression::Config::unicode()) {
		thread::sleep(Duration::from_millis(1));
	}

	// Uses `slice.chunks` internally for lower overhead on large numbers of items
	for _ in progression::bar_chunks(10, &[0; 1_000]) {
		thread::sleep(Duration::from_millis(1));
	}

	// Custom
	for _ in progression::bar_with_config(0..1_000, progression::Config { style: progression::Style::Mono('·'), ..Default::default() }) {
		thread::sleep(Duration::from_millis(1));
	}

	// Manual
	let items = vec![1, 2, 3, 4, 5];
	let bar = progression::Bar::new(items.len() as u64, progression::Config { prefix: "(items) ", ..progression::Config::cargo() });

	for _ in items {
		thread::sleep(Duration::from_millis(100));
		bar.inc(1);
	}

	bar.finish();
}
source

pub fn inc(&self, delta: u64)

Examples found in repository?
examples/example.rs (line 35)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
fn main() {
	// Default
	for _ in progression::bar(0..1_000) {
		thread::sleep(Duration::from_millis(1));
	}

	// Cargo style
	for _ in progression::bar_with_config(0..1_000, progression::Config::cargo()) {
		thread::sleep(Duration::from_millis(1));
	}

	// Unicode style
	for _ in progression::bar_with_config(0..1_000, progression::Config::unicode()) {
		thread::sleep(Duration::from_millis(1));
	}

	// Uses `slice.chunks` internally for lower overhead on large numbers of items
	for _ in progression::bar_chunks(10, &[0; 1_000]) {
		thread::sleep(Duration::from_millis(1));
	}

	// Custom
	for _ in progression::bar_with_config(0..1_000, progression::Config { style: progression::Style::Mono('·'), ..Default::default() }) {
		thread::sleep(Duration::from_millis(1));
	}

	// Manual
	let items = vec![1, 2, 3, 4, 5];
	let bar = progression::Bar::new(items.len() as u64, progression::Config { prefix: "(items) ", ..progression::Config::cargo() });

	for _ in items {
		thread::sleep(Duration::from_millis(100));
		bar.inc(1);
	}

	bar.finish();
}
source

pub fn finish(self)

Examples found in repository?
examples/example.rs (line 38)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
fn main() {
	// Default
	for _ in progression::bar(0..1_000) {
		thread::sleep(Duration::from_millis(1));
	}

	// Cargo style
	for _ in progression::bar_with_config(0..1_000, progression::Config::cargo()) {
		thread::sleep(Duration::from_millis(1));
	}

	// Unicode style
	for _ in progression::bar_with_config(0..1_000, progression::Config::unicode()) {
		thread::sleep(Duration::from_millis(1));
	}

	// Uses `slice.chunks` internally for lower overhead on large numbers of items
	for _ in progression::bar_chunks(10, &[0; 1_000]) {
		thread::sleep(Duration::from_millis(1));
	}

	// Custom
	for _ in progression::bar_with_config(0..1_000, progression::Config { style: progression::Style::Mono('·'), ..Default::default() }) {
		thread::sleep(Duration::from_millis(1));
	}

	// Manual
	let items = vec![1, 2, 3, 4, 5];
	let bar = progression::Bar::new(items.len() as u64, progression::Config { prefix: "(items) ", ..progression::Config::cargo() });

	for _ in items {
		thread::sleep(Duration::from_millis(100));
		bar.inc(1);
	}

	bar.finish();
}

Trait Implementations§

source§

impl Drop for Bar<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Bar<'a>

§

impl<'a> Send for Bar<'a>

§

impl<'a> Sync for Bar<'a>

§

impl<'a> Unpin for Bar<'a>

§

impl<'a> UnwindSafe for Bar<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.