Struct lucia_lang::objects::Table
source · pub struct Table {
pub array: Vec<(Value, Value)>,
pub mapping: IndexMap<Value, Value>,
pub metatable: Value,
}Expand description
The table implement.
Fields§
§array: Vec<(Value, Value)>§mapping: IndexMap<Value, Value>§metatable: ValueImplementations§
source§impl Table
impl Table
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty Table.
The table is initially created with a capacity of 0, so it will not allocate until it is first inserted into.
sourcepub fn iter(&self) -> Iter<'_>
pub fn iter(&self) -> Iter<'_>
Return an iterator over the key-value pairs of the table, in their order.
sourcepub fn iter_mut(&mut self) -> IterMut<'_>
pub fn iter_mut(&mut self) -> IterMut<'_>
Return an iterator over the key-value pairs of the table, in their order.
sourcepub fn into_keys(self) -> IntoKeys
pub fn into_keys(self) -> IntoKeys
Return an owning iterator over the keys of the table, in their order.
sourcepub fn values(&self) -> Values<'_>
pub fn values(&self) -> Values<'_>
Return an iterator over the values of the table, in their order.
sourcepub fn values_mut(&mut self) -> ValuesMut<'_>
pub fn values_mut(&mut self) -> ValuesMut<'_>
Return an iterator over mutable references to the values of the table, in their order.
sourcepub fn into_values(self) -> IntoValues
pub fn into_values(self) -> IntoValues
Return an owning iterator over the values of the table, in their order.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of key-value pairs in the table.
Computes in O(1) time.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the table contains no elements.
Computes in O(1) time.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all key-value pairs in the table, while preserving its capacity.
Computes in O(n) time.
sourcepub fn get_index(&self, index: usize) -> Option<(&Value, &Value)>
pub fn get_index(&self, index: usize) -> Option<(&Value, &Value)>
Get a key-value pair by index.
Valid indices are 0 <= index < self.len().
Computes in O(1) time.
sourcepub fn get_index_mut(
&mut self,
index: usize
) -> Option<(&mut Value, &mut Value)>
pub fn get_index_mut( &mut self, index: usize ) -> Option<(&mut Value, &mut Value)>
Get a key-value pair by index.
Valid indices are 0 <= index < self.len().
Computes in O(1) time.
sourcepub fn get(&self, key: &Value) -> Option<&Value>
pub fn get(&self, key: &Value) -> Option<&Value>
Return a reference to the value stored for key, if it is present,
else None.
Computes in O(1) time (average).
Trait Implementations§
source§impl Extend<(Value, Value)> for Table
impl Extend<(Value, Value)> for Table
source§fn extend<T: IntoIterator<Item = (Value, Value)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (Value, Value)>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl Extend<Value> for Table
impl Extend<Value> for Table
source§fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl FromIterator<Value> for Table
impl FromIterator<Value> for Table
source§impl<'a> IntoIterator for &'a Table
impl<'a> IntoIterator for &'a Table
source§impl<'a> IntoIterator for &'a mut Table
impl<'a> IntoIterator for &'a mut Table
source§impl IntoIterator for Table
impl IntoIterator for Table
source§impl PartialEq<Table> for Table
impl PartialEq<Table> for Table
impl Eq for Table
impl StructuralEq for Table
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl !RefUnwindSafe for Table
impl !Send for Table
impl !Sync for Table
impl Unpin for Table
impl !UnwindSafe for Table
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.