macro_rules! fuse {
($($command:expr),+ $(,)?) => { ... };
}
Expand description
Combine several commands into a single new command.
The new command preserves the order of its component commands. Upon display, it emits as many ANSI escape sequence as it has component commands. Upon debug, it reveals the macro’s source arguments.
Since commands in the cmd
module generally implement
Clone
, Copy
, Debug
, PartialEq
, and Eq
,
fused commands do so, too. However, since DynLink
and DynSetWindowTitle
have string-valued
fields and hence cannot implement Copy
, these two commands cannot be
fused.
When fusing only SGR commands, prefer fuse_sgr!
, which
generates commands that emit a single ANSI escape sequence only.
§Example
let move_down_right_twice = fuse!(MoveDown::<2>, MoveRight::<2>);
assert_eq!(format!("{}", move_down_right_twice), "\x1b[2B\x1b[2D");