2 ms·
fn compose<T>( f1: impl Fn(T)->T, f2: impl Fn(T)->T ) -> impl Fn(T)->T { // both arguments as well as the returned value
by iknowstuff 7y ago
fn compose<T>(
f1: impl Fn(T)->T,
f2: impl Fn(T)->T
) -> impl Fn(T)->T
{
// both arguments as well as the returned value
// are functions which take and return the generic type T.
// (to be precise, they implement the Fn trait).
}
let returned_function = compose(|val| val == 1, |val| val < 0);
let value: bool = returned_function(true);