pub struct NativeFn {
pub name: String,
pub func: Box<NativeFnInner>,
pub payload: Option<Rc<dyn Any>>,
pub is_closure: bool,
}Fields§
§name: String§func: Box<NativeFnInner>§payload: Option<Rc<dyn Any>>§is_closure: boolTrue when this NativeFn is actually the fallback wrapper for a VM
closure (a user-defined lambda/fn), not a genuine builtin. The VM
represents closures as NativeFns carrying a VmClosurePayload; this
flag lets type/type_name report :lambda instead of :native-fn
without sema-core/sema-stdlib needing to know the VM’s payload type.
Implementations§
Source§impl NativeFn
impl NativeFn
pub fn simple( name: impl Into<String>, f: impl Fn(&[Value]) -> Result<Value, SemaError> + 'static, ) -> Self
pub fn with_ctx( name: impl Into<String>, f: impl Fn(&EvalContext, &[Value]) -> Result<Value, SemaError> + 'static, ) -> Self
pub fn with_payload( name: impl Into<String>, payload: Rc<dyn Any>, f: impl Fn(&EvalContext, &[Value]) -> Result<Value, SemaError> + 'static, ) -> Self
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for NativeFn
impl !Send for NativeFn
impl !Sync for NativeFn
impl !UnwindSafe for NativeFn
impl Freeze for NativeFn
impl Unpin for NativeFn
impl UnsafeUnpin for NativeFn
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