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: Value

Implementations§

source§

impl Table

source

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.

source

pub fn iter(&self) -> Iter<'_>

Return an iterator over the key-value pairs of the table, in their order.

source

pub fn iter_mut(&mut self) -> IterMut<'_>

Return an iterator over the key-value pairs of the table, in their order.

source

pub fn keys(&self) -> Keys<'_>

Return an iterator over the keys of the table, in their order.

source

pub fn into_keys(self) -> IntoKeys

Return an owning iterator over the keys of the table, in their order.

source

pub fn values(&self) -> Values<'_>

Return an iterator over the values of the table, in their order.

source

pub fn values_mut(&mut self) -> ValuesMut<'_>

Return an iterator over mutable references to the values of the table, in their order.

source

pub fn into_values(self) -> IntoValues

Return an owning iterator over the values of the table, in their order.

source

pub fn len(&self) -> usize

Return the number of key-value pairs in the table.

Computes in O(1) time.

source

pub fn is_empty(&self) -> bool

Returns true if the table contains no elements.

Computes in O(1) time.

source

pub fn clear(&mut self)

Remove all key-value pairs in the table, while preserving its capacity.

Computes in O(n) time.

source

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.

source

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.

source

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).

source

pub fn get_mut(&mut self, key: &Value) -> Option<&mut Value>

Return a mutable reference to the value stored for key, if it is present, else None.

Computes in O(1) time (average).

source

pub fn set(&mut self, key: &Value, value: Value)

Insert a key-value pair in the table.

Computes in O(1) time (amortized average).

Trait Implementations§

source§

impl Clone for Table

source§

fn clone(&self) -> Table

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Table

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Table

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Table

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Extend<(Value, Value)> for Table

source§

fn extend<T: IntoIterator<Item = (Value, Value)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Value> for Table

source§

fn extend<T: IntoIterator<Item = Value>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<const N: usize> From<[(Value, Value); N]> for Table

source§

fn from(arr: [(Value, Value); N]) -> Self

Converts to this type from the input type.
source§

impl<const N: usize> From<[Value; N]> for Table

source§

fn from(arr: [Value; N]) -> Self

Converts to this type from the input type.
source§

impl FromIterator<(Value, Value)> for Table

source§

fn from_iter<T: IntoIterator<Item = (Value, Value)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Value> for Table

source§

fn from_iter<T: IntoIterator<Item = Value>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Index<&Value> for Table

§

type Output = Value

The returned type after indexing.
source§

fn index(&self, index: &Value) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<'a> IntoIterator for &'a Table

§

type Item = (&'a Value, &'a Value)

The type of the elements being iterated over.
§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a> IntoIterator for &'a mut Table

§

type Item = (&'a Value, &'a mut Value)

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for Table

§

type Item = (Value, Value)

The type of the elements being iterated over.
§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq<Table> for Table

source§

fn eq(&self, other: &Table) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Trace for Table

source§

unsafe fn trace(&self)

Marks all contained Gcs.
source§

unsafe fn marked(&self) -> bool

Is this object marked.
source§

impl Eq for Table

source§

impl StructuralEq for Table

source§

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<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.