Trait rocket_dyn_templates::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.

There are also further restrictions imposed on borrowing in some situations. For instance you cannot implicitly borrow out of sequences which means that for instance Vec<&str> is not a legal argument.

§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§

source

type Output

The output type of this argument.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> ArgType<'a> for &str

source§

type Output = &'a str

source§

impl<'a> ArgType<'a> for &[u8]

source§

type Output = &'a [u8]

source§

impl<'a> ArgType<'a> for &[Value]

source§

type Output = &'a [Value]

source§

impl<'a> ArgType<'a> for Cow<'_, str>

source§

type Output = Cow<'a, str>

source§

impl<'a> ArgType<'a> for bool

source§

impl<'a> ArgType<'a> for char

source§

impl<'a> ArgType<'a> for f32

source§

impl<'a> ArgType<'a> for f64

source§

impl<'a> ArgType<'a> for i8

source§

impl<'a> ArgType<'a> for i16

source§

impl<'a> ArgType<'a> for i32

source§

impl<'a> ArgType<'a> for i64

source§

impl<'a> ArgType<'a> for i128

source§

impl<'a> ArgType<'a> for u8

source§

impl<'a> ArgType<'a> for u16

source§

impl<'a> ArgType<'a> for u32

source§

impl<'a> ArgType<'a> for u64

source§

impl<'a> ArgType<'a> for u128

source§

impl<'a> ArgType<'a> for usize

source§

impl<'a> ArgType<'a> for String

source§

impl<'a> ArgType<'a> for Arc<str>

source§

impl<'a, T> ArgType<'a> for Option<T>
where T: ArgType<'a>,

source§

type Output = Option<<T as ArgType<'a>>::Output>

source§

impl<'a, T> ArgType<'a> for &T
where T: Object + 'static,

source§

impl<'a, T> ArgType<'a> for Arc<T>
where T: Object + 'static,

source§

impl<'a, T> ArgType<'a> for Vec<T>
where T: ArgType<'a, Output = T>,

Implementors§

source§

impl<'a> ArgType<'a> for &State<'_, '_>

source§

type Output = &'a State<'a, 'a>

source§

impl<'a> ArgType<'a> for &Value

source§

impl<'a> ArgType<'a> for Value

source§

impl<'a> ArgType<'a> for DynObject

source§

impl<'a> ArgType<'a> for Kwargs

source§

impl<'a, T> ArgType<'a> for Rest<T>
where T: ArgType<'a, Output = T>,

source§

impl<'a, T> ArgType<'a> for ViaDeserialize<T>
where T: Deserialize<'a>,