Struct arithmetic_eval::fns::Merge
source · pub struct Merge;
Expand description
Function that merges two tuples.
§Type
(using arithmetic-typing
notation)
(['T], ['T]) -> ['T]
§Examples
let program = "
// Merges all arguments (which should be tuples) into a single tuple.
super_merge = |...xs| fold(xs, (), merge);
super_merge((1, 2), (3,), (), (4, 5, 6)) == (1, 2, 3, 4, 5, 6)
";
let program = Untyped::<F32Grammar>::parse_statements(program)?;
let module = ExecutableModule::new("test_merge", &program)?;
let mut env = Environment::new();
env.insert_native_fn("fold", fns::Fold)
.insert_native_fn("merge", fns::Merge);
assert_eq!(module.with_env(&env)?.run()?, Value::Bool(true));
Trait Implementations§
source§impl<T: Clone> NativeFn<T> for Merge
impl<T: Clone> NativeFn<T> for Merge
source§fn evaluate(
&self,
args: Vec<SpannedValue<T>>,
ctx: &mut CallContext<'_, T>,
) -> EvalResult<T>
fn evaluate( &self, args: Vec<SpannedValue<T>>, ctx: &mut CallContext<'_, T>, ) -> EvalResult<T>
Executes the function on the specified arguments.
impl Copy for Merge
Auto Trait Implementations§
impl Freeze for Merge
impl RefUnwindSafe for Merge
impl Send for Merge
impl Sync for Merge
impl Unpin for Merge
impl UnwindSafe for Merge
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)