#[repr(transparent)]pub struct DynamicReturn<T> {
pub data: Cell,
/* private fields */
}
Expand description
A type for a function’s return value that may have a more dynamic casting nature than usual.
The analyzer will assume that the return type belongs to the
type family of the T
type, but the
Script Engine will not automatically upcast the Rust value,
allowing the implementation to manually cast the result into a Cell.
#[export]
fn string_or_number(is_string: bool) -> RuntimeResult<DynamicReturn<usize>> {
match is_string {
true => Ok(DynamicReturn::new(Cell::give(Origin::nil(), "string")?)),
false => Ok(DynamicReturn::new(Cell::give(Origin::nil(), 100usize)?)),
}
}
Fields§
§data: Cell
The underlying return object.
Implementations§
Trait Implementations§
Source§impl<'a, T: ScriptType> Upcast<'a> for DynamicReturn<T>
impl<'a, T: ScriptType> Upcast<'a> for DynamicReturn<T>
Auto Trait Implementations§
impl<T> Freeze for DynamicReturn<T>
impl<T> !RefUnwindSafe for DynamicReturn<T>
impl<T> Send for DynamicReturn<T>where
T: Send,
impl<T> Sync for DynamicReturn<T>where
T: Sync,
impl<T> Unpin for DynamicReturn<T>where
T: Unpin,
impl<T> !UnwindSafe for DynamicReturn<T>
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