diff --git a/minijinja/src/value/mod.rs b/minijinja/src/value/mod.rs index 20f1fe1a..ad16817a 100644 --- a/minijinja/src/value/mod.rs +++ b/minijinja/src/value/mod.rs @@ -435,6 +435,28 @@ impl Value { ValueRepr::Dynamic(value as Arc).into() } + /// Creates a value from a vector of values. + /// + /// Unlike the existing `TryFrom>>`, this method involves + /// not additional allocations. + /// + /// ```rust + /// use std::sync::Arc; + /// # use minijinja::value::Value; + /// + /// let values = (0..10).into_iter() + /// .map(Value::from) + /// .collect::>(); + /// + /// let v = Value::from_vec(values); + /// + /// let values = Arc::new(vec![Value::from("hello")]); + /// let v = Value::from_vec(values); + /// ``` + pub fn from_vec>>>(values: V) -> Value { + ValueRepr::Seq(values.into()).into() + } + /// Creates a callable value from a function. /// /// ```