pub struct Table<'gc>(/* private fields */);Implementations§
Source§impl<'gc> Table<'gc>
impl<'gc> Table<'gc>
pub fn new(mc: &Mutation<'gc>) -> Table<'gc>
pub fn from_parts( mc: &Mutation<'gc>, raw_table: RawTable<'gc>, metatable: Option<Table<'gc>>, ) -> Table<'gc>
pub fn from_inner(inner: Gc<'gc, TableInner<'gc>>) -> Self
pub fn into_inner(self) -> Gc<'gc, TableInner<'gc>>
pub fn get<K: IntoValue<'gc>>(self, ctx: Context<'gc>, key: K) -> Value<'gc>
pub fn set<K: IntoValue<'gc>, V: IntoValue<'gc>>( self, ctx: Context<'gc>, key: K, value: V, ) -> Result<Value<'gc>, InvalidTableKey>
pub fn get_value(self, key: Value<'gc>) -> Value<'gc>
pub fn set_value( self, mc: &Mutation<'gc>, key: Value<'gc>, value: Value<'gc>, ) -> Result<Value<'gc>, InvalidTableKey>
Sourcepub fn length(self) -> i64
pub fn length(self) -> i64
Returns a ‘border’ for this table.
A ‘border’ for a table is any i >= 0 where:
(i == 0 or table[i] ~= nil) and table[i + 1] == nil
If a table has exactly one border, it is called a ‘sequence’, and this border is the table’s length.
Sourcepub fn next(self, key: Value<'gc>) -> NextValue<'gc>
pub fn next(self, key: Value<'gc>) -> NextValue<'gc>
Returns the next value after this key in the table order.
The table order in the map portion of the table is defined by the incidental order of the internal bucket list. This order may change whenever the bucket list changes size, such as when inserting into the table, so relying on the order while inserting may result in unspecified (but not unsafe) behavior.
If given Nil, it will return the first pair in the table. If given a key that is present in the table, it will return the next pair in iteration order. If given a key that is not present in the table, the behavior is unspecified.
Sourcepub fn iter(self) -> Iter<'gc>
pub fn iter(self) -> Iter<'gc>
Iterate over the key-value pairs of the table.
Internally uses the Table::next method and thus matches the behavior of Lua.
pub fn metatable(self) -> Option<Table<'gc>>
pub fn set_metatable( self, mc: &Mutation<'gc>, metatable: Option<Table<'gc>>, ) -> Option<Table<'gc>>
Trait Implementations§
Source§impl<'gc> Collect for Table<'gc>
impl<'gc> Collect for Table<'gc>
Source§fn needs_trace() -> bool
fn needs_trace() -> bool
Gc pointer and trace is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace must be called.Source§fn trace(&self, cc: &Collection)
fn trace(&self, cc: &Collection)
Collect::trace on all held Gc pointers. If this type holds inner types that
implement Collect, a valid implementation would simply call Collect::trace on all the
held values to ensure this.