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>
impl<M: Display, T: Clone, O: Display + Clone> MultiSelect<M, T, O>
Sourcepub fn new(message: M) -> Self
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");
Sourcepub fn option(&mut self, val: T, label: O) -> &mut Self
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
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}
Sourcepub fn option_hint<S: ToString>(
&mut self,
val: T,
label: O,
hint: S,
) -> &mut Self
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
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}
Sourcepub fn options(&mut self, options: Vec<Opt<T, O>>) -> &mut Self
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);
Sourcepub fn less(&mut self) -> &mut Self
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}
Sourcepub fn less_max(&mut self, max: u16) -> &mut Self
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);
Sourcepub fn less_amt(&mut self, less: u16) -> &mut Self
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}
Sourcepub fn cancel<F>(&mut self, cancel: F) -> &mut Selfwhere
F: Fn() + 'static,
pub fn cancel<F>(&mut self, cancel: F) -> &mut Selfwhere
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
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}
Sourcepub fn interact(&self) -> Result<Vec<T>, ClackError>
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
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>
impl<M, T, O> !UnwindSafe for MultiSelect<M, T, O>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
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,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Set the background color generically. Read more
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Change the foreground color to black
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Change the background color to black
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Change the foreground color to red
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Change the background color to red
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Change the foreground color to green
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Change the background color to green
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Change the foreground color to yellow
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Change the background color to yellow
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Change the foreground color to blue
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Change the background color to blue
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to magenta
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to magenta
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to purple
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to purple
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Change the foreground color to cyan
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Change the background color to cyan
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Change the foreground color to white
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Change the background color to white
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Change the foreground color to the terminal default
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Change the background color to the terminal default
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Change the foreground color to bright black
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Change the background color to bright black
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Change the foreground color to bright red
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Change the background color to bright red
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Change the foreground color to bright green
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Change the background color to bright green
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Change the foreground color to bright yellow
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Change the background color to bright yellow
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Change the foreground color to bright blue
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Change the background color to bright blue
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright magenta
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright magenta
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright purple
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright purple
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Change the foreground color to bright cyan
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Change the background color to bright cyan
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Change the foreground color to bright white
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Change the background color to bright white
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Make the text bold
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Make the text dim
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Make the text italicized
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Make the text underlined
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Make the text blink
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Make the text blink (but fast!)
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Swap the foreground and background colors
Hide the text
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Cross out the text
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
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 moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
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 moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
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>
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>
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>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.