Struct Macro

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Source

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.

Source

pub fn nr_arguments(self, nr: NrArguments) -> Self

Configure required nr of arguments for the macro

Trait Implementations§

Source§

impl Debug for Macro

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Macro

§

impl RefUnwindSafe for Macro

§

impl Send for Macro

§

impl Sync for Macro

§

impl Unpin for Macro

§

impl UnwindSafe for Macro

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.