File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,15 @@ pub trait GenericCombinators {
122122 fn chain_opt < X > ( self , o : Option < X > , f : impl FnOnce ( Self , X ) -> Self ) -> Self
123123 where
124124 Self : Sized ;
125+
126+ /// Helper method to revert function application order.
127+ /// ```
128+ /// # use famedly_rust_utils::GenericCombinators;
129+ /// "huge multiline expression here".apply_to(|x| println!("{x}"));
130+ /// ```
131+ fn apply_to < X > ( self , f : impl FnOnce ( Self ) -> X ) -> X
132+ where
133+ Self : Sized ;
125134}
126135
127136impl < A > GenericCombinators for A {
@@ -151,6 +160,11 @@ impl<A> GenericCombinators for A {
151160 self
152161 }
153162 }
163+
164+ #[ inline]
165+ fn apply_to < X > ( self , f : impl FnOnce ( Self ) -> X ) -> X {
166+ f ( self )
167+ }
154168}
155169
156170/// Helper function to convert values to `()`
You can’t perform that action at this time.
0 commit comments