pub fn substitution<A: Copy, B, C, F, G>(f: F, g: G, x: A) -> Cwhere
    F: FnOnce(A, B) -> C,
    G: FnOnce(A) -> B,
Expand description

This substitution function, also known as S (Starling) combinator, is used when you have a binary function and you can supply the first argument and can use that value to create the second argument.

Example

use rust2fun::prelude::*;

let generate = |s: &str, l: usize| format!("The string \"{}\" has a length of {}", s, l);
let actual = substitution(generate, str::len, "Hello, World!");
assert_eq!("The string \"Hello, World!\" has a length of 13", actual);