#[non_exhaustive]pub struct Macro {
pub input: Cow<'static, str>,
pub arguments: Option<usize>,
}
Expand description
A struct representing a runnable macro
It is intended to add more/change the variables, but the constructors should produce instances with the same behaviour through any changes.
If the serde
feature is enabled, serialization will produce the most
backwards compatible representation while still ensuring the same behaviour.
Deserialization should produce identically behaving macros when valid for
the version of add-ed
being used, if newer features are used in the macro
than the deserializing version of add-ed
has access to an unknown field
error will be raised.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.input: Cow<'static, str>
Input to simulate
Should be a string of newline separated commands. Execution is equivalent to if this input was given on STDIN while the editor is running.
arguments: Option<usize>
The number of arguments the macro accepts
None means there is no specific number, disabling validation of correct nr of given arguments before execution. Some(0) means the macro expects no arguments, as such no argument substitution will be performed.
Implementations§
source§impl Macro
impl Macro
sourcepub fn new<T: Into<Cow<'static, str>>>(input: T, arguments: usize) -> Self
pub fn new<T: Into<Cow<'static, str>>>(input: T, arguments: usize) -> Self
Construct a macro
Creates a macro with the given text as command input and the given nr of allowed arguments. If 0 arguments expected no argument substitution will be performed for the macro.
sourcepub fn without_arg_validation<T: Into<Cow<'static, str>>>(input: T) -> Self
pub fn without_arg_validation<T: Into<Cow<'static, str>>>(input: T) -> Self
Construct a macro that takes any number of commands
Creates a macro with the given text as command input and disables validation of nr of arguments to the macro. This is intended for macros using the “all arguments” substitutor instead of numbered argument substitutors.