Function rocket_dyn_templates::minijinja::value::from_args
source ยท pub fn from_args<'a, Args>(values: &'a [Value]) -> Result<Args, Error>where
Args: FunctionArgs<'a, Output = Args>,
Expand description
Utility function to convert a slice of values into arguments.
This performs the same conversion that Function
performs. It exists so that you one can leverage the same functionality when
implementing Object::call_method
.
// args is &[Value]
let (string, num): (&str, i64) = from_args(args)?;
Note that only value conversions are supported which means that &State
is not
a valid conversion type.
You can also use this function to split positional and keyword arguments (Kwargs
):
// args is &[Value], kwargs is Kwargs
let (args, kwargs): (&[Value], Kwargs) = from_args(args)?;