pub struct DynamicType;
Expand description
A type that cannot be inferred during static semantic analysis.
Normally, you should not instantiate or use this object in implementations, but you can use this type as a hint for the analyzer when the implementation nature is fully dynamic.
struct Foo;
#[export]
type FooAlias = Foo;
#[export]
impl ScriptAssign for Foo {
// `type RHS = Foo;` would be more preferable in this case.
type RHS = DynamicType;
fn script_assign(_origin: Origin, lhs: Arg, rhs: Arg) -> RuntimeResult<()> {
let rhs = rhs.data.take::<Foo>(rhs.origin)?;
let (lhs_origin, mut lhs_cell) = lhs.split();
let lhs = lhs_cell.borrow_mut::<Foo>(lhs_origin)?;
*lhs = rhs;
Ok(())
}
}
Generally, it is recommended to use this type as sparingly as possible, preferring more specific types even if they provide an imprecise description.
If you need more control over the exported function’s arguments and result type casting, consider using DynamicArgument and DynamicReturn wrappers instead.
Auto Trait Implementations§
impl Freeze for DynamicType
impl RefUnwindSafe for DynamicType
impl Send for DynamicType
impl Sync for DynamicType
impl Unpin for DynamicType
impl UnwindSafe for DynamicType
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