Struct debris_llir::debris_object::ObjectRef
source · pub struct ObjectRef(Rc<DebrisObject<dyn ObjectPayload>>);
Expand description
This struct is used to pass objects around
Objects references are read-only, so values that can be modified must be declared in a cell.
Tuple Fields§
§0: Rc<DebrisObject<dyn ObjectPayload>>
Implementations§
source§impl ObjectRef
impl ObjectRef
pub fn from_payload<T: ObjectPayload>(ctx: &TypeContext, value: T) -> Self
Methods from Deref<Target = DebrisObject<dyn ObjectPayload>>§
sourcepub fn get_property(
&self,
ctx: &TypeContext,
ident: &Ident
) -> Option<ObjectRef>
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.
sourcepub fn downcast_payload<T: ObjectPayload>(&self) -> Option<&T>
pub fn downcast_payload<T: ObjectPayload>(&self) -> Option<&T>
Converts the payload into its original type
Returns None if the downcast is not possible
sourcepub fn downcast_class(&self) -> Option<ClassRef>
pub fn downcast_class(&self) -> Option<ClassRef>
Helper function for downcasting the payload into a class
Trait Implementations§
source§impl Deref for ObjectRef
impl Deref for ObjectRef
§type Target = DebrisObject<dyn ObjectPayload>
type Target = DebrisObject<dyn ObjectPayload>
The resulting type after dereferencing.
source§impl<T: ObjectPayload> From<DebrisObject<T>> for ObjectRef
impl<T: ObjectPayload> From<DebrisObject<T>> for ObjectRef
source§fn from(object: DebrisObject<T>) -> Self
fn from(object: DebrisObject<T>) -> Self
Converts to this type from the input type.
source§impl PartialEq for ObjectRef
impl PartialEq for ObjectRef
source§impl ValidReturnType for ObjectRef
impl ValidReturnType for ObjectRef
fn into_result( self, _ctx: &mut FunctionContext<'_, '_, '_> ) -> Option<LangResult<ObjectRef>>
impl Eq for ObjectRef
Auto Trait Implementations§
impl !RefUnwindSafe for ObjectRef
impl !Send for ObjectRef
impl !Sync for ObjectRef
impl Unpin for ObjectRef
impl !UnwindSafe for ObjectRef
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.