Struct Config

Source
pub struct Config<'a> {
    pub width: Option<u64>,
    pub default_width: u64,
    pub delimiters: (char, char),
    pub style: Style,
    pub space_char: char,
    pub prefix: &'a str,
    pub unit: &'a str,
    pub num_width: usize,
    pub throttle_millis: u64,
}

Fields§

§width: Option<u64>§default_width: u64§delimiters: (char, char)§style: Style§space_char: char§prefix: &'a str§unit: &'a str§num_width: usize§throttle_millis: u64

Implementations§

Source§

impl Config<'_>

Source

pub fn ascii() -> Self

Source

pub fn unicode() -> Self

Examples found in repository?
examples/example.rs (line 15)
3fn main() {
4	// Default
5	for _ in progression::bar(0..1_000) {
6		thread::sleep(Duration::from_millis(1));
7	}
8
9	// Cargo style
10	for _ in progression::bar_with_config(0..1_000, progression::Config::cargo()) {
11		thread::sleep(Duration::from_millis(1));
12	}
13
14	// Unicode style
15	for _ in progression::bar_with_config(0..1_000, progression::Config::unicode()) {
16		thread::sleep(Duration::from_millis(1));
17	}
18
19	// Uses `slice.chunks` internally for lower overhead on large numbers of items
20	for _ in progression::bar_chunks(10, &[0; 1_000]) {
21		thread::sleep(Duration::from_millis(1));
22	}
23
24	// Custom
25	for _ in progression::bar_with_config(0..1_000, progression::Config { style: progression::Style::Mono('·'), ..Default::default() }) {
26		thread::sleep(Duration::from_millis(1));
27	}
28
29	// Manual
30	let items = vec![1, 2, 3, 4, 5];
31	let bar = progression::Bar::new(items.len() as u64, progression::Config { prefix: "(items) ", ..progression::Config::cargo() });
32
33	for _ in items {
34		thread::sleep(Duration::from_millis(100));
35		bar.inc(1);
36	}
37
38	bar.finish();
39}
Source

pub fn cargo() -> Self

Examples found in repository?
examples/example.rs (line 10)
3fn main() {
4	// Default
5	for _ in progression::bar(0..1_000) {
6		thread::sleep(Duration::from_millis(1));
7	}
8
9	// Cargo style
10	for _ in progression::bar_with_config(0..1_000, progression::Config::cargo()) {
11		thread::sleep(Duration::from_millis(1));
12	}
13
14	// Unicode style
15	for _ in progression::bar_with_config(0..1_000, progression::Config::unicode()) {
16		thread::sleep(Duration::from_millis(1));
17	}
18
19	// Uses `slice.chunks` internally for lower overhead on large numbers of items
20	for _ in progression::bar_chunks(10, &[0; 1_000]) {
21		thread::sleep(Duration::from_millis(1));
22	}
23
24	// Custom
25	for _ in progression::bar_with_config(0..1_000, progression::Config { style: progression::Style::Mono('·'), ..Default::default() }) {
26		thread::sleep(Duration::from_millis(1));
27	}
28
29	// Manual
30	let items = vec![1, 2, 3, 4, 5];
31	let bar = progression::Bar::new(items.len() as u64, progression::Config { prefix: "(items) ", ..progression::Config::cargo() });
32
33	for _ in items {
34		thread::sleep(Duration::from_millis(100));
35		bar.inc(1);
36	}
37
38	bar.finish();
39}

Trait Implementations§

Source§

impl<'a> Clone for Config<'a>

Source§

fn clone(&self) -> Config<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Config<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Config<'a>

§

impl<'a> RefUnwindSafe for Config<'a>

§

impl<'a> Send for Config<'a>

§

impl<'a> Sync for Config<'a>

§

impl<'a> Unpin for Config<'a>

§

impl<'a> UnwindSafe for Config<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.