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