mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
imp(macros.rs): Added write_nspaces macro (a new version of write_spaces)
`write_nspaces` has three differences with `write_spaces` 1. Accepts arguments with attribute access (such as self.writer) 2. The order of the arguments is swapped to make the writer the first argument as in other write related macros. 3. Does not use the `write!` macro under the hood but rather calls directly `write` I have chosen to put the function under a new name to avoid backwards compatibility problem but it might be better to migrate everything to `write_nspaces` (and maybe rename it `write_spaces`)
This commit is contained in:
parent
65b3f66753
commit
9d757e8678
1 changed files with 13 additions and 0 deletions
|
@ -586,6 +586,19 @@ macro_rules! write_spaces {
|
|||
})
|
||||
}
|
||||
|
||||
// Helper/deduplication macro for printing the correct number of spaces in help messages
|
||||
// used in:
|
||||
// src/args/arg_builder/*.rs
|
||||
// src/app/mod.rs
|
||||
macro_rules! write_nspaces {
|
||||
($dst:expr, $num:expr) => ({
|
||||
debugln!("macro=write_spaces!;");
|
||||
for _ in 0..$num {
|
||||
try!($dst.write(b" "));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// convenience macro for remove an item from a vec
|
||||
macro_rules! vec_remove {
|
||||
($vec:expr, $to_rem:expr) => {
|
||||
|
|
Loading…
Reference in a new issue