mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Replace MultiValue::extend_from_values with from_lua_iter
This commit is contained in:
+1
-3
@@ -177,9 +177,7 @@ impl<T> DerefMut for Variadic<T> {
|
||||
impl<T: IntoLua> IntoLuaMulti for Variadic<T> {
|
||||
#[inline]
|
||||
fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue> {
|
||||
let mut values = MultiValue::with_capacity(self.0.len());
|
||||
values.extend_from_values(self.0.into_iter().map(|val| val.into_lua(lua)))?;
|
||||
Ok(values)
|
||||
MultiValue::from_lua_iter(lua, self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -814,11 +814,13 @@ impl MultiValue {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn extend_from_values(&mut self, iter: impl IntoIterator<Item = Result<Value>>) -> Result<()> {
|
||||
pub(crate) fn from_lua_iter<T: IntoLua>(lua: &Lua, iter: impl IntoIterator<Item = T>) -> Result<Self> {
|
||||
let iter = iter.into_iter();
|
||||
let mut multi_value = MultiValue::with_capacity(iter.size_hint().0);
|
||||
for value in iter {
|
||||
self.push_back(value?);
|
||||
multi_value.push_back(value.into_lua(lua)?);
|
||||
}
|
||||
Ok(())
|
||||
Ok(multi_value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user