Skip to main content

BopStruct

Struct BopStruct 

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

A user-defined struct value. Carries the module it was declared in plus the bare type name, so two modules that happen to declare struct Color { ... } independently produce distinct values even when they share a name. The module path is <root> for the top-level program and <builtin> for engine-registered builtins like RuntimeError; for user modules it’s the dot-joined use path ("std.math", "game.entity", …). Fields are stored in declaration order so iteration and Display stay stable.

Implementations§

Source§

impl BopStruct

Source

pub fn type_name(&self) -> &str

Source

pub fn module_path(&self) -> &str

Module this struct type was declared in. Forms one half of the type’s identity — the other half is the bare Self::type_name.

Source

pub fn fields(&self) -> &[(String, Value)]

Source

pub fn field(&self, name: &str) -> Option<&Value>

Look up a field by name. None if no such field.

Source

pub fn set_field(&mut self, name: &str, value: Value) -> bool

Replace the value of an existing field. Returns true if the field was present; false if the caller should raise a “no such field” error. The old value is dropped (firing its allocation tracking); no capacity change in the Vec.

Trait Implementations§

Source§

impl Debug for BopStruct

Source§

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

Formats the value using the given formatter. 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 = Infallible

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.