macro_rules! show {
($expr:expr $(, sep=$sep:expr)? $(, end=$end:expr)? $(,)? $(=> $buf:expr)?) => { ... };
($expr:expr, end=$end:expr $(, sep=$sep:expr)? $(,)? $(=> $buf:expr)?) => { ... };
}Expand description
Write the given expression into standard output using WriteInto.
The intended grammar is:
ⓘ
show!($expr:expr $(, sep=$sep:expr)? $(, end=$end:expr)? $(,)? $(=> $buf:expr)?)You can configure the writer using the following options:
sep: Separator between values. Default is" ". Provide an instance of Separators to use custom separators, and if it has mismatched dimensions, it may use the default separator (if there is one) or panic.end: End of the output. Default is"\n". Provide a string to use a custom end.buf: Buffer to write into. Default is standard output. Provide a mutable reference to a buffer that implements std::io::Write to write into it.
fn main() {
use iof::show;
// This will write "42\n" to the standard output.
show!(42);
// This will write "Hello, World!\n" to the standard output.
show!("Hello, World!");
// This will write "1 2 3 4\n" to the standard output.
show!([1, 2, 3, 4]);
// This will write "1 2\n3 4\n" to the standard output.
show!([[1, 2], [3, 4]]);
// This will write "1, 2\n3, 4\n" to the standard output.
show!([[1, 2], [3, 4]], sep = ["\n", ", "]);
// This will write "1, 2\n3, 4!" to the standard output.
show!([[1, 2], [3, 4]], sep = ["\n", ", "], end = "!\n");
// This will write "1,2;3,4!" to the standard output.
show!([[1, 2], [3, 4]], sep = [';', ','], end = "!\n");
}