Trait minijinja::value::ArgType

source ·
pub trait ArgType<'a> {
    type Output;
}
Expand description

A trait implemented by all filter/test argument types.

This trait is used by FunctionArgs. It’s implemented for many common types that are typically passed to filters, tests or functions. It’s implemented for the following types:

The type is also implemented for optional values (Option<T>) which is used to encode optional parameters to filters, functions or tests. Additionally it’s implemented for Rest<T> which is used to encode the remaining arguments of a function call.

Notes on Borrowing

Note on that there is an important difference between String and &str: the former will be valid for all values and an implicit conversion to string via ToString will take place, for the latter only values which are already strings will be passed. A compromise between the two is Cow<'_, str> which will behave like String but borrows when possible.

Byte slices will borrow out of values carrying bytes or strings. In the latter case the utf-8 bytes are returned.

Notes on State

When &State is used, it does not consume a passed parameter. This means that a filter that takes (&State, String) actually only has one argument. The state is passed implicitly.

Required Associated Types

The output type of this argument.

Implementations on Foreign Types

Implementors