xbasic 0.3.2

A library that allows adding a scripting language onto your project with ease. This lets your users write their own arbitrary logic.
Documentation
use crate::expr::ExprValue;

pub(crate) struct NativeFunctionDefinition {
	pub(crate) name: String,
	pub(crate) arity: u8,
}

impl NativeFunctionDefinition {
	pub(crate) fn new(name: String, arity: u8) -> Self {
		Self { name, arity }
	}
}

pub(crate) struct NativeFunction<T> {
	pub(crate) name: String,
	pub(crate) arity: u8,
	pub(crate) function: Box<dyn Fn(Vec<ExprValue>, &mut T) -> ExprValue>,
}

impl<T> NativeFunction<T> {
	pub(crate) fn new<F: 'static>(name: String, arity: u8, function: F) -> Self
	where
		F: Fn(Vec<ExprValue>, &mut T) -> ExprValue,
	{
		Self {
			name,
			arity,
			function: Box::new(function),
		}
	}
}