#[non_exhaustive]pub struct Macro {
pub input: Cow<'static, str>,
pub nr_arguments: NrArguments,
}
Expand description
A struct representing a runnable macro
It is intended to add more/change the variables, but the constructor and any thereafter applied modification should produces 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.
nr_arguments: NrArguments
The number of arguments the macro accepts
Any
performs no validation, Exactly
verifies that it is exactly that
nr of arguments given, and if None
is set no argument substitution is
run on the macro (which means ’$’s don’t need to be doubled in the macro).
Implementations§
Source§impl Macro
impl Macro
Sourcepub fn new<T: Into<Cow<'static, str>>>(input: T) -> Self
pub fn new<T: Into<Cow<'static, str>>>(input: T) -> Self
Construct a macro
Creates a macro with the given text as command input and all other options default. Use the builder pattern operators below or modify the public member variables to configure the rest.
Sourcepub fn nr_arguments(self, nr: NrArguments) -> Self
pub fn nr_arguments(self, nr: NrArguments) -> Self
Configure required nr of arguments for the macro