Skip to content

Commit

Permalink
Replace MultiValue::extend_from_values with from_lua_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Aug 6, 2024
1 parent f0a995a commit 10999ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 10999ba

Please sign in to comment.