Skip to main content

VarTable

Struct VarTable 

Source
pub struct VarTable { /* private fields */ }
Expand description

The world’s variables, in slot order: shared across behaviors, so slots are assigned once across the whole set. A name the world’s Variables asset declares carries that declaration’s type and starting value; any other name a behavior mentions is an integer starting at zero.

Implementations§

Source§

impl VarTable

Source

pub fn declare(&mut self, name: &str, init: Val)

Declare a variable with its authored type and starting value. A repeated name keeps its first declaration; the world checker rejects duplicates.

Source

pub fn slot_of(&self, name: &str) -> Option<u16>

The slot a name was assigned, if it has one.

Source

pub fn names(&self) -> &[String]

Every declared name, in slot order.

Source

pub fn initial(&self) -> Vec<Val>

The starting values, in slot order.

Source

pub fn init_of(&self, name: &str) -> Option<Val>

The starting value a name was declared with, if it has a slot.

Trait Implementations§

Source§

impl Debug for VarTable

Source§

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

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

impl Default for VarTable

Source§

fn default() -> VarTable

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.