rust_overture/
with.rs

1/// Left-to-right function application (pipe-forward).
2///
3/// Equivalent to `f(a)`.
4pub fn with<A, B>(a: A, f: impl FnOnce(A) -> B) -> B {
5    f(a)
6}
7
8pub fn with_mut<A>(mut a: A, mut f: impl FnMut(&mut A)) -> A {
9    f(&mut a);
10    a
11}
12
13#[macro_export]
14macro_rules! with_macro {
15    ($val:expr, $f:expr) => {
16        $crate::with($val, $f)
17    };
18}