on

Function on 

Source
pub fn on<A, B, C, F, G>(f: F, g: G, x: A, y: A) -> C
where F: FnOnce(B, B) -> C, G: FnMut(A) -> B,
Expand description

This function, also called the Psi combinator, allows you to call a function on transformations of values. It can be considered the sister of converge. Where converge takes one argument and maps it through two unary functions, merging the resulting values with a binary function, psi takes two arguments and runs them each through the same unary function before merging them with the given binary function.

ยงExample

use rust2fun::prelude::*;

let equals = |x, y| x == y;
let actual = on(equals, str::to_lowercase, "Str", "STR");
assert_eq!(true, actual);