pub trait FunMut<T: HList>: FunOnce<T> {
// Required method
fn call_fun_mut(&mut self, args: T) -> Self::Output;
}Expand description
Helper trait to use heterogenous lists as arguments for FnMuts.
TODO: remove or keep depending on https://github.com/rust-lang/rust/issues/29625
Required Methods§
Sourcefn call_fun_mut(&mut self, args: T) -> Self::Output
fn call_fun_mut(&mut self, args: T) -> Self::Output
Calls self using the elements of the given list as arguments.
§Examples
§On HCons
use tuplify::*;
let list = hcons![0, '1', "2"];
let mut value = String::new();
let mut func = |x: i32, y: char, z: &str| value = format!("{x} {y} {z}");
func.call_fun_mut(list);
assert_eq!(&value, "0 1 2");Also works on functions taking no arguments:
use tuplify::*;
let mut value = String::new();
let mut func = || value = "hello".to_string();
func.call_fun_mut(HEmpty);
assert_eq!(&value, "hello");§On tuples
use tuplify::*;
let list = (0, '1', "2");
let mut value = String::new();
let mut func = |x: i32, y: char, z: &str| value = format!("{x} {y} {z}");
func.call_fun_mut(list);
assert_eq!(&value, "0 1 2");On a function taking no arguments:
use tuplify::*;
let mut value = String::new();
let mut func = || value = "hello".to_string();
func.call_fun_mut(());
assert_eq!(&value, "hello");