|
1 | 1 | use std::cmp::Ordering; |
2 | | -use std::collections::{vec_deque, HashSet, VecDeque}; |
3 | | -use std::ops::{Deref, DerefMut}; |
| 2 | +use std::collections::HashSet; |
4 | 3 | use std::os::raw::c_void; |
5 | 4 | use std::string::String as StdString; |
6 | | -use std::{fmt, mem, ptr, str}; |
| 5 | +use std::{fmt, ptr, str}; |
7 | 6 |
|
8 | 7 | use num_traits::FromPrimitive; |
9 | 8 |
|
10 | 9 | use crate::error::{Error, Result}; |
11 | 10 | use crate::function::Function; |
12 | | -use crate::state::Lua; |
13 | 11 | use crate::string::{BorrowedStr, String}; |
14 | 12 | use crate::table::Table; |
15 | 13 | use crate::thread::Thread; |
16 | | -use crate::traits::IntoLua; |
17 | 14 | use crate::types::{Integer, LightUserData, Number, ValueRef}; |
18 | 15 | use crate::userdata::AnyUserData; |
19 | 16 | use crate::util::{check_stack, StackGuard}; |
@@ -735,91 +732,12 @@ impl<'a> Serialize for SerializableValue<'a> { |
735 | 732 | } |
736 | 733 | } |
737 | 734 |
|
738 | | -/// Multiple Lua values used for both argument passing and also for multiple return values. |
739 | | -#[derive(Default, Debug, Clone)] |
740 | | -pub struct MultiValue(VecDeque<Value>); |
741 | | - |
742 | | -impl Deref for MultiValue { |
743 | | - type Target = VecDeque<Value>; |
744 | | - |
745 | | - #[inline] |
746 | | - fn deref(&self) -> &Self::Target { |
747 | | - &self.0 |
748 | | - } |
749 | | -} |
750 | | - |
751 | | -impl DerefMut for MultiValue { |
752 | | - #[inline] |
753 | | - fn deref_mut(&mut self) -> &mut Self::Target { |
754 | | - &mut self.0 |
755 | | - } |
756 | | -} |
757 | | - |
758 | | -impl MultiValue { |
759 | | - /// Creates an empty `MultiValue` containing no values. |
760 | | - #[inline] |
761 | | - pub const fn new() -> MultiValue { |
762 | | - MultiValue(VecDeque::new()) |
763 | | - } |
764 | | - |
765 | | - /// Creates an empty `MultiValue` container with space for at least `capacity` elements. |
766 | | - pub fn with_capacity(capacity: usize) -> MultiValue { |
767 | | - MultiValue(VecDeque::with_capacity(capacity)) |
768 | | - } |
769 | | - |
770 | | - #[inline] |
771 | | - pub(crate) fn from_lua_iter<T: IntoLua>(lua: &Lua, iter: impl IntoIterator<Item = T>) -> Result<Self> { |
772 | | - let iter = iter.into_iter(); |
773 | | - let mut multi_value = MultiValue::with_capacity(iter.size_hint().0); |
774 | | - for value in iter { |
775 | | - multi_value.push_back(value.into_lua(lua)?); |
776 | | - } |
777 | | - Ok(multi_value) |
778 | | - } |
779 | | -} |
780 | | - |
781 | | -impl FromIterator<Value> for MultiValue { |
782 | | - #[inline] |
783 | | - fn from_iter<I: IntoIterator<Item = Value>>(iter: I) -> Self { |
784 | | - let mut multi_value = MultiValue::new(); |
785 | | - multi_value.extend(iter); |
786 | | - multi_value |
787 | | - } |
788 | | -} |
789 | | - |
790 | | -impl IntoIterator for MultiValue { |
791 | | - type Item = Value; |
792 | | - type IntoIter = vec_deque::IntoIter<Value>; |
793 | | - |
794 | | - #[inline] |
795 | | - fn into_iter(mut self) -> Self::IntoIter { |
796 | | - let deque = mem::take(&mut self.0); |
797 | | - mem::forget(self); |
798 | | - deque.into_iter() |
799 | | - } |
800 | | -} |
801 | | - |
802 | | -impl<'a> IntoIterator for &'a MultiValue { |
803 | | - type Item = &'a Value; |
804 | | - type IntoIter = vec_deque::Iter<'a, Value>; |
805 | | - |
806 | | - #[inline] |
807 | | - fn into_iter(self) -> Self::IntoIter { |
808 | | - self.0.iter() |
809 | | - } |
810 | | -} |
811 | | - |
812 | 735 | #[cfg(test)] |
813 | 736 | mod assertions { |
814 | 737 | use super::*; |
815 | 738 |
|
816 | 739 | #[cfg(not(feature = "send"))] |
817 | 740 | static_assertions::assert_not_impl_any!(Value: Send); |
818 | | - #[cfg(not(feature = "send"))] |
819 | | - static_assertions::assert_not_impl_any!(MultiValue: Send); |
820 | | - |
821 | 741 | #[cfg(feature = "send")] |
822 | 742 | static_assertions::assert_impl_all!(Value: Send, Sync); |
823 | | - #[cfg(feature = "send")] |
824 | | - static_assertions::assert_impl_all!(MultiValue: Send, Sync); |
825 | 743 | } |
0 commit comments