Macro conciliator::inline
source · macro_rules! inline { ($($item:expr),*) => { ... }; }
Expand description
Concatenate Pushable
types to become Inline
as one
This macro takes any number of unambiguously Pushable
values (Expressions to be precise) and returns a value that, when Inline
d, pushes all the provided values into the buffer.
Simply put, it concatenates all of its arguments into a single value that implements Inline
.
For example:
let con = conciliator::init();
use conciliator::{Conciliator, inline};
con.status(inline!("Hello", ' ', "World", '!'));
Prints:
[ > ] Hello World!
Using it like this, it is only very slightly different to using format_args!
, but crucially, it is very easy to adjust this example to color the word World
with Color::Beta
and to make both words bold:
let con = conciliator::init();
use conciliator::{Conciliator, inline, WrapBold as Bold};
con.status(inline!(Bold::Plain("Hello"), ' ', Bold::Beta("World"), '!'));
In this case, the inline!
macro is just slightly more concise than appending to the status
Line
before printing it (by dropping it), but in other cases, like creating a List
with a header, using this macro is significantly more ergonomic than the alternatives.
E.g.
let con = conciliator::init();
use conciliator::{List, inline, WrapBold::Plain as Bold};
List::headless(0..3)
.with_count(inline!(Bold("bold"), " numbers"))
.with_wrap(Bold)
.print_to(&con);
Prints the list with a header like this:
[ > ] 3
bold
numbers: