pub struct DebrisObject<T: ObjectPayload + ?Sized> {
    pub class: ClassRef,
    pub payload: T,
}
Expand description

Objects are a central type for the compiler. Basically anything that can be assigned to a variable is an object. This includes numbers, function, modules, and more. It is possible to cast the ObjectPayload to its original value. Because DebrisObject is unsized, it generally only accessed as ObjectRef

Fields§

§class: ClassRef

The class of the object

§payload: T

The actual value

Implementations§

source§

impl DebrisObject<dyn ObjectPayload>

source

pub fn get_property( &self, ctx: &TypeContext, ident: &Ident ) -> Option<ObjectRef>

Tries to get a property that belongs to this object

First tries to retrieve the property from its payload. If that fails, tries to retrieve the property from its class.

source

pub fn downcast_payload<T: ObjectPayload>(&self) -> Option<&T>

Converts the payload into its original type

Returns None if the downcast is not possible

source

pub fn downcast_class(&self) -> Option<ClassRef>

Helper function for downcasting the payload into a class

Trait Implementations§

source§

impl Debug for DebrisObject<dyn ObjectPayload>

source§

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

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

impl<T: ObjectPayload> From<DebrisObject<T>> for ObjectRef

source§

fn from(object: DebrisObject<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for DebrisObject<T>

§

impl<T> !Send for DebrisObject<T>

§

impl<T> !Sync for DebrisObject<T>

§

impl<T: ?Sized> Unpin for DebrisObject<T>where T: Unpin,

§

impl<T> !UnwindSafe for DebrisObject<T>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.