Struct MultiSelect

Source
pub struct MultiSelect<M: Display, T: Clone, O: Display + Clone> { /* private fields */ }
Expand description

MultiSelect struct

§Examples

use may_clack::multi_select;

let answer = multi_select("select")
    .option("val1", "value 1")
    .option("val2", "value 2")
    .option_hint("val 3", "value 3", "hint")
    .interact()?;
println!("answer {:?}", answer);

Implementations§

Source§

impl<M: Display, T: Clone, O: Display + Clone> MultiSelect<M, T, O>

Source

pub fn new(message: M) -> Self

Creates a new MultiSelect struct.

Has a shorthand version in multi_select()

§Examples
use may_clack::{multi_select, multi_select::MultiSelect};

// these two are equivalent
let mut question = MultiSelect::new("message");
question.option("value", "hint");

let mut question = multi_select("message");
question.option("value", "hint");
Source

pub fn option(&mut self, val: T, label: O) -> &mut Self

Add an option without a hint.

§Examples
use may_clack::multi_select;

let answer = multi_select("message")
    .option("val1", "label 1")
    .option("val2", "label 2")
    .interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/single.rs (line 12)
4fn main() -> Result<(), ClackError> {
5	println!();
6	intro!(" single ".reversed());
7	let do_single_select = select("single")
8		.option("one", "one")
9		.cancel(do_cancel)
10		.interact()?;
11	let do_single_multi = multi_select("single")
12		.option("one", "one")
13		.cancel(do_cancel)
14		.interact()?;
15
16	outro!();
17
18	println!("select {:?}", do_single_select);
19	println!("multi {:?}", do_single_multi);
20
21	Ok(())
22}
More examples
Hide additional examples
examples/generic_select.rs (line 34)
22fn main() -> Result<(), ClackError> {
23	println!();
24	intro!(" generic select ".reversed());
25
26	let select_enum = select("select enum")
27		.option(SelectEnum::One, SelectEnum::One)
28		.option(SelectEnum::Two, SelectEnum::Two)
29		.option(SelectEnum::Three, SelectEnum::Three)
30		.cancel(do_cancel)
31		.interact()?;
32
33	let multi_enum = multi_select("multi_select enum")
34		.option(SelectEnum::One, "one")
35		.option(SelectEnum::Two, "two")
36		.option(SelectEnum::Three, "three")
37		.cancel(do_cancel)
38		.interact()?;
39
40	outro!();
41
42	println!("select enum, label enum {:?}", select_enum);
43	println!("multi select enum, label string {:?}", multi_enum);
44
45	Ok(())
46}
examples/full.rs (line 26)
7fn main() -> Result<(), ClackError> {
8	println!();
9	intro!(" full ".reversed());
10
11	info!("visit the documentation at https://docs.rs/may-clack");
12
13	let do_input = input("input")
14		.placeholder("placeholder")
15		.cancel(do_cancel)
16		.required()?;
17	let do_multi_input = multi_input("multi input")
18		.max(4)
19		.cancel(do_cancel)
20		.interact()?;
21	let do_confirm = confirm("confirm")
22		.prompts("true", "false")
23		.cancel(do_cancel)
24		.interact()?;
25	let do_multi_select = multi_select("multi select")
26		.option("opt1", "option 1")
27		.option("opt2", "option 2")
28		.option_hint("opt3", "option 3", "hint")
29		.cancel(do_cancel)
30		.interact()?;
31	let do_select = select("select")
32		.option("val1", "value 1")
33		.option("val2", "value 2")
34		.option_hint("val 3", "value 3", "hint")
35		.cancel(do_cancel)
36		.interact()?;
37
38	outro!();
39
40	println!("input {:?}", do_input);
41	println!("confirm {:?}", do_confirm);
42	println!("multi_input {:?}", do_multi_input);
43	println!("multi_select {:?}", do_multi_select);
44	println!("select {:?}", do_select);
45
46	Ok(())
47}
examples/less.rs (line 23)
8fn main() -> Result<(), ClackError> {
9	println!();
10	intro!(" less ".reversed());
11
12	let select_less = select("less")
13		.option("val 1", "value 1")
14		.option("val 2", "value 2")
15		.option_hint("val 3", "value 3", "hint")
16		.option("val 4", "value 4")
17		.option("val 5", "value 5")
18		.less_amt(3)
19		.cancel(do_cancel)
20		.interact()?;
21
22	let multi_less_noop = multi_select("less")
23		.option("val 1", "value 1")
24		.option("val 2", "value 2")
25		.option_hint("val 3", "value 3", "hint")
26		.less_amt(5)
27		.cancel(do_cancel)
28		.interact()?;
29
30	let multi_less = multi_select("less")
31		.option("val 1", "value 1")
32		.option("val 2", "value 2")
33		.option_hint("val 3", "value 3", "hint")
34		.option("val 4", "value 4")
35		.option("val 5", "value 5")
36		.less()
37		.cancel(do_cancel)
38		.interact()?;
39
40	let mut page_up_down = select("page up / down");
41	page_up_down.less_max(25);
42	page_up_down.cancel(do_cancel);
43
44	for i in 0..100 {
45		page_up_down.option(i, i);
46	}
47
48	let page_up_down = page_up_down.interact()?;
49
50	outro!();
51
52	println!("page_up_down {:?}", page_up_down);
53	println!("select_less {:?}", select_less);
54	println!("multi_less_noop {:?}", multi_less_noop);
55	println!("multi_less {:?}", multi_less);
56
57	Ok(())
58}
Source

pub fn option_hint<S: ToString>( &mut self, val: T, label: O, hint: S, ) -> &mut Self

Add an option with a hint.

§Examples
use may_clack::multi_select;

let answer = multi_select("message")
    .option("val1", "label 1")
    .option_hint("val2", "label 2", "hint")
    .option("val3", "label 3")
    .interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/full.rs (line 28)
7fn main() -> Result<(), ClackError> {
8	println!();
9	intro!(" full ".reversed());
10
11	info!("visit the documentation at https://docs.rs/may-clack");
12
13	let do_input = input("input")
14		.placeholder("placeholder")
15		.cancel(do_cancel)
16		.required()?;
17	let do_multi_input = multi_input("multi input")
18		.max(4)
19		.cancel(do_cancel)
20		.interact()?;
21	let do_confirm = confirm("confirm")
22		.prompts("true", "false")
23		.cancel(do_cancel)
24		.interact()?;
25	let do_multi_select = multi_select("multi select")
26		.option("opt1", "option 1")
27		.option("opt2", "option 2")
28		.option_hint("opt3", "option 3", "hint")
29		.cancel(do_cancel)
30		.interact()?;
31	let do_select = select("select")
32		.option("val1", "value 1")
33		.option("val2", "value 2")
34		.option_hint("val 3", "value 3", "hint")
35		.cancel(do_cancel)
36		.interact()?;
37
38	outro!();
39
40	println!("input {:?}", do_input);
41	println!("confirm {:?}", do_confirm);
42	println!("multi_input {:?}", do_multi_input);
43	println!("multi_select {:?}", do_multi_select);
44	println!("select {:?}", do_select);
45
46	Ok(())
47}
More examples
Hide additional examples
examples/less.rs (line 25)
8fn main() -> Result<(), ClackError> {
9	println!();
10	intro!(" less ".reversed());
11
12	let select_less = select("less")
13		.option("val 1", "value 1")
14		.option("val 2", "value 2")
15		.option_hint("val 3", "value 3", "hint")
16		.option("val 4", "value 4")
17		.option("val 5", "value 5")
18		.less_amt(3)
19		.cancel(do_cancel)
20		.interact()?;
21
22	let multi_less_noop = multi_select("less")
23		.option("val 1", "value 1")
24		.option("val 2", "value 2")
25		.option_hint("val 3", "value 3", "hint")
26		.less_amt(5)
27		.cancel(do_cancel)
28		.interact()?;
29
30	let multi_less = multi_select("less")
31		.option("val 1", "value 1")
32		.option("val 2", "value 2")
33		.option_hint("val 3", "value 3", "hint")
34		.option("val 4", "value 4")
35		.option("val 5", "value 5")
36		.less()
37		.cancel(do_cancel)
38		.interact()?;
39
40	let mut page_up_down = select("page up / down");
41	page_up_down.less_max(25);
42	page_up_down.cancel(do_cancel);
43
44	for i in 0..100 {
45		page_up_down.option(i, i);
46	}
47
48	let page_up_down = page_up_down.interact()?;
49
50	outro!();
51
52	println!("page_up_down {:?}", page_up_down);
53	println!("select_less {:?}", select_less);
54	println!("multi_less_noop {:?}", multi_less_noop);
55	println!("multi_less {:?}", multi_less);
56
57	Ok(())
58}
Source

pub fn options(&mut self, options: Vec<Opt<T, O>>) -> &mut Self

Add multiple options.

§Examples
use may_clack::{multi_select, multi_select::Opt};

let opts = vec![
    Opt::simple("val1", "label 1"),
    Opt::hint("val2", "label 2", "hint"),
    Opt::simple("val3", "label 3"),
];

let answer = multi_select("message").options(opts).interact()?;
println!("answer {:?}", answer);
Source

pub fn less(&mut self) -> &mut Self

Enable paging with the amount of terminal rows.

§Examples
use may_clack::multi_select;

let answer = multi_select("message")
    .option("val 1", "value 1")
    .option("val 2", "value 2")
    .option_hint("val 3", "value 3", "hint")
    .option("val 4", "value 4")
    .option("val 5", "value 5")
    .less()
    .interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/less.rs (line 36)
8fn main() -> Result<(), ClackError> {
9	println!();
10	intro!(" less ".reversed());
11
12	let select_less = select("less")
13		.option("val 1", "value 1")
14		.option("val 2", "value 2")
15		.option_hint("val 3", "value 3", "hint")
16		.option("val 4", "value 4")
17		.option("val 5", "value 5")
18		.less_amt(3)
19		.cancel(do_cancel)
20		.interact()?;
21
22	let multi_less_noop = multi_select("less")
23		.option("val 1", "value 1")
24		.option("val 2", "value 2")
25		.option_hint("val 3", "value 3", "hint")
26		.less_amt(5)
27		.cancel(do_cancel)
28		.interact()?;
29
30	let multi_less = multi_select("less")
31		.option("val 1", "value 1")
32		.option("val 2", "value 2")
33		.option_hint("val 3", "value 3", "hint")
34		.option("val 4", "value 4")
35		.option("val 5", "value 5")
36		.less()
37		.cancel(do_cancel)
38		.interact()?;
39
40	let mut page_up_down = select("page up / down");
41	page_up_down.less_max(25);
42	page_up_down.cancel(do_cancel);
43
44	for i in 0..100 {
45		page_up_down.option(i, i);
46	}
47
48	let page_up_down = page_up_down.interact()?;
49
50	outro!();
51
52	println!("page_up_down {:?}", page_up_down);
53	println!("select_less {:?}", select_less);
54	println!("multi_less_noop {:?}", multi_less_noop);
55	println!("multi_less {:?}", multi_less);
56
57	Ok(())
58}
Source

pub fn less_max(&mut self, max: u16) -> &mut Self

Enable paging with the amount of terminal rows, additionally setting a maximum amount.

§Panics

Panics when the given value is 0.
Panics when called after MultiSelect::less_amt has already been called.

§Examples
use may_clack::multi_select;

let answer = multi_select("message")
    .option("val 1", "value 1")
    .option("val 2", "value 2")
    .option_hint("val 3", "value 3", "hint")
    .option("val 4", "value 4")
    .option("val 5", "value 5")
    .less_max(3)
    .interact()?;
println!("answer {:?}", answer);
Source

pub fn less_amt(&mut self, less: u16) -> &mut Self

Enable paging with the specified amount of lines.

§Panics

Panics when the given value is 0.
Panics when called after MultiSelect::less_max has already been called.

§Examples
use may_clack::multi_select;

let answer = multi_select("message")
    .option("val 1", "value 1")
    .option("val 2", "value 2")
    .option_hint("val 3", "value 3", "hint")
    .option("val 4", "value 4")
    .option("val 5", "value 5")
    .less_amt(3)
    .interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/less.rs (line 26)
8fn main() -> Result<(), ClackError> {
9	println!();
10	intro!(" less ".reversed());
11
12	let select_less = select("less")
13		.option("val 1", "value 1")
14		.option("val 2", "value 2")
15		.option_hint("val 3", "value 3", "hint")
16		.option("val 4", "value 4")
17		.option("val 5", "value 5")
18		.less_amt(3)
19		.cancel(do_cancel)
20		.interact()?;
21
22	let multi_less_noop = multi_select("less")
23		.option("val 1", "value 1")
24		.option("val 2", "value 2")
25		.option_hint("val 3", "value 3", "hint")
26		.less_amt(5)
27		.cancel(do_cancel)
28		.interact()?;
29
30	let multi_less = multi_select("less")
31		.option("val 1", "value 1")
32		.option("val 2", "value 2")
33		.option_hint("val 3", "value 3", "hint")
34		.option("val 4", "value 4")
35		.option("val 5", "value 5")
36		.less()
37		.cancel(do_cancel)
38		.interact()?;
39
40	let mut page_up_down = select("page up / down");
41	page_up_down.less_max(25);
42	page_up_down.cancel(do_cancel);
43
44	for i in 0..100 {
45		page_up_down.option(i, i);
46	}
47
48	let page_up_down = page_up_down.interact()?;
49
50	outro!();
51
52	println!("page_up_down {:?}", page_up_down);
53	println!("select_less {:?}", select_less);
54	println!("multi_less_noop {:?}", multi_less_noop);
55	println!("multi_less {:?}", multi_less);
56
57	Ok(())
58}
Source

pub fn cancel<F>(&mut self, cancel: F) -> &mut Self
where F: Fn() + 'static,

Specify function to call on cancel.

§Examples
use may_clack::{multi_select, cancel};

let answer = multi_select("select")
    .option("val1", "value 1")
    .option("val2", "value 2")
    .option_hint("val 3", "value 3", "hint")
    .cancel(do_cancel)
    .interact()?;
println!("answer {:?}", answer);

fn do_cancel() {
    cancel!("operation cancelled");
    panic!("operation cancelled");
}
Examples found in repository?
examples/single.rs (line 13)
4fn main() -> Result<(), ClackError> {
5	println!();
6	intro!(" single ".reversed());
7	let do_single_select = select("single")
8		.option("one", "one")
9		.cancel(do_cancel)
10		.interact()?;
11	let do_single_multi = multi_select("single")
12		.option("one", "one")
13		.cancel(do_cancel)
14		.interact()?;
15
16	outro!();
17
18	println!("select {:?}", do_single_select);
19	println!("multi {:?}", do_single_multi);
20
21	Ok(())
22}
More examples
Hide additional examples
examples/generic_select.rs (line 37)
22fn main() -> Result<(), ClackError> {
23	println!();
24	intro!(" generic select ".reversed());
25
26	let select_enum = select("select enum")
27		.option(SelectEnum::One, SelectEnum::One)
28		.option(SelectEnum::Two, SelectEnum::Two)
29		.option(SelectEnum::Three, SelectEnum::Three)
30		.cancel(do_cancel)
31		.interact()?;
32
33	let multi_enum = multi_select("multi_select enum")
34		.option(SelectEnum::One, "one")
35		.option(SelectEnum::Two, "two")
36		.option(SelectEnum::Three, "three")
37		.cancel(do_cancel)
38		.interact()?;
39
40	outro!();
41
42	println!("select enum, label enum {:?}", select_enum);
43	println!("multi select enum, label string {:?}", multi_enum);
44
45	Ok(())
46}
examples/full.rs (line 29)
7fn main() -> Result<(), ClackError> {
8	println!();
9	intro!(" full ".reversed());
10
11	info!("visit the documentation at https://docs.rs/may-clack");
12
13	let do_input = input("input")
14		.placeholder("placeholder")
15		.cancel(do_cancel)
16		.required()?;
17	let do_multi_input = multi_input("multi input")
18		.max(4)
19		.cancel(do_cancel)
20		.interact()?;
21	let do_confirm = confirm("confirm")
22		.prompts("true", "false")
23		.cancel(do_cancel)
24		.interact()?;
25	let do_multi_select = multi_select("multi select")
26		.option("opt1", "option 1")
27		.option("opt2", "option 2")
28		.option_hint("opt3", "option 3", "hint")
29		.cancel(do_cancel)
30		.interact()?;
31	let do_select = select("select")
32		.option("val1", "value 1")
33		.option("val2", "value 2")
34		.option_hint("val 3", "value 3", "hint")
35		.cancel(do_cancel)
36		.interact()?;
37
38	outro!();
39
40	println!("input {:?}", do_input);
41	println!("confirm {:?}", do_confirm);
42	println!("multi_input {:?}", do_multi_input);
43	println!("multi_select {:?}", do_multi_select);
44	println!("select {:?}", do_select);
45
46	Ok(())
47}
examples/less.rs (line 27)
8fn main() -> Result<(), ClackError> {
9	println!();
10	intro!(" less ".reversed());
11
12	let select_less = select("less")
13		.option("val 1", "value 1")
14		.option("val 2", "value 2")
15		.option_hint("val 3", "value 3", "hint")
16		.option("val 4", "value 4")
17		.option("val 5", "value 5")
18		.less_amt(3)
19		.cancel(do_cancel)
20		.interact()?;
21
22	let multi_less_noop = multi_select("less")
23		.option("val 1", "value 1")
24		.option("val 2", "value 2")
25		.option_hint("val 3", "value 3", "hint")
26		.less_amt(5)
27		.cancel(do_cancel)
28		.interact()?;
29
30	let multi_less = multi_select("less")
31		.option("val 1", "value 1")
32		.option("val 2", "value 2")
33		.option_hint("val 3", "value 3", "hint")
34		.option("val 4", "value 4")
35		.option("val 5", "value 5")
36		.less()
37		.cancel(do_cancel)
38		.interact()?;
39
40	let mut page_up_down = select("page up / down");
41	page_up_down.less_max(25);
42	page_up_down.cancel(do_cancel);
43
44	for i in 0..100 {
45		page_up_down.option(i, i);
46	}
47
48	let page_up_down = page_up_down.interact()?;
49
50	outro!();
51
52	println!("page_up_down {:?}", page_up_down);
53	println!("select_less {:?}", select_less);
54	println!("multi_less_noop {:?}", multi_less_noop);
55	println!("multi_less {:?}", multi_less);
56
57	Ok(())
58}
Source

pub fn interact(&self) -> Result<Vec<T>, ClackError>

Wait for the user to submit the selected options.

§Examples
use may_clack::multi_select;

let answer = multi_select("select")
    .option("val1", "value 1")
    .option("val2", "value 2")
    .option_hint("val 3", "value 3", "hint")
    .interact()?;
println!("answer {:?}", answer);
Examples found in repository?
examples/single.rs (line 14)
4fn main() -> Result<(), ClackError> {
5	println!();
6	intro!(" single ".reversed());
7	let do_single_select = select("single")
8		.option("one", "one")
9		.cancel(do_cancel)
10		.interact()?;
11	let do_single_multi = multi_select("single")
12		.option("one", "one")
13		.cancel(do_cancel)
14		.interact()?;
15
16	outro!();
17
18	println!("select {:?}", do_single_select);
19	println!("multi {:?}", do_single_multi);
20
21	Ok(())
22}
More examples
Hide additional examples
examples/generic_select.rs (line 38)
22fn main() -> Result<(), ClackError> {
23	println!();
24	intro!(" generic select ".reversed());
25
26	let select_enum = select("select enum")
27		.option(SelectEnum::One, SelectEnum::One)
28		.option(SelectEnum::Two, SelectEnum::Two)
29		.option(SelectEnum::Three, SelectEnum::Three)
30		.cancel(do_cancel)
31		.interact()?;
32
33	let multi_enum = multi_select("multi_select enum")
34		.option(SelectEnum::One, "one")
35		.option(SelectEnum::Two, "two")
36		.option(SelectEnum::Three, "three")
37		.cancel(do_cancel)
38		.interact()?;
39
40	outro!();
41
42	println!("select enum, label enum {:?}", select_enum);
43	println!("multi select enum, label string {:?}", multi_enum);
44
45	Ok(())
46}
examples/full.rs (line 30)
7fn main() -> Result<(), ClackError> {
8	println!();
9	intro!(" full ".reversed());
10
11	info!("visit the documentation at https://docs.rs/may-clack");
12
13	let do_input = input("input")
14		.placeholder("placeholder")
15		.cancel(do_cancel)
16		.required()?;
17	let do_multi_input = multi_input("multi input")
18		.max(4)
19		.cancel(do_cancel)
20		.interact()?;
21	let do_confirm = confirm("confirm")
22		.prompts("true", "false")
23		.cancel(do_cancel)
24		.interact()?;
25	let do_multi_select = multi_select("multi select")
26		.option("opt1", "option 1")
27		.option("opt2", "option 2")
28		.option_hint("opt3", "option 3", "hint")
29		.cancel(do_cancel)
30		.interact()?;
31	let do_select = select("select")
32		.option("val1", "value 1")
33		.option("val2", "value 2")
34		.option_hint("val 3", "value 3", "hint")
35		.cancel(do_cancel)
36		.interact()?;
37
38	outro!();
39
40	println!("input {:?}", do_input);
41	println!("confirm {:?}", do_confirm);
42	println!("multi_input {:?}", do_multi_input);
43	println!("multi_select {:?}", do_multi_select);
44	println!("select {:?}", do_select);
45
46	Ok(())
47}
examples/less.rs (line 28)
8fn main() -> Result<(), ClackError> {
9	println!();
10	intro!(" less ".reversed());
11
12	let select_less = select("less")
13		.option("val 1", "value 1")
14		.option("val 2", "value 2")
15		.option_hint("val 3", "value 3", "hint")
16		.option("val 4", "value 4")
17		.option("val 5", "value 5")
18		.less_amt(3)
19		.cancel(do_cancel)
20		.interact()?;
21
22	let multi_less_noop = multi_select("less")
23		.option("val 1", "value 1")
24		.option("val 2", "value 2")
25		.option_hint("val 3", "value 3", "hint")
26		.less_amt(5)
27		.cancel(do_cancel)
28		.interact()?;
29
30	let multi_less = multi_select("less")
31		.option("val 1", "value 1")
32		.option("val 2", "value 2")
33		.option_hint("val 3", "value 3", "hint")
34		.option("val 4", "value 4")
35		.option("val 5", "value 5")
36		.less()
37		.cancel(do_cancel)
38		.interact()?;
39
40	let mut page_up_down = select("page up / down");
41	page_up_down.less_max(25);
42	page_up_down.cancel(do_cancel);
43
44	for i in 0..100 {
45		page_up_down.option(i, i);
46	}
47
48	let page_up_down = page_up_down.interact()?;
49
50	outro!();
51
52	println!("page_up_down {:?}", page_up_down);
53	println!("select_less {:?}", select_less);
54	println!("multi_less_noop {:?}", multi_less_noop);
55	println!("multi_less {:?}", multi_less);
56
57	Ok(())
58}

Auto Trait Implementations§

§

impl<M, T, O> Freeze for MultiSelect<M, T, O>
where M: Freeze,

§

impl<M, T, O> !RefUnwindSafe for MultiSelect<M, T, O>

§

impl<M, T, O> !Send for MultiSelect<M, T, O>

§

impl<M, T, O> !Sync for MultiSelect<M, T, O>

§

impl<M, T, O> Unpin for MultiSelect<M, T, O>
where M: Unpin, T: Unpin, O: Unpin,

§

impl<M, T, O> !UnwindSafe for MultiSelect<M, T, O>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
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.