Guest User

Untitled

a guest
Nov 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. struct Functor<Type, ReturnType> {
  2. let method: (Type) -> ReturnType
  3.  
  4. func run(_ value: Type) -> ReturnType {
  5. return method(value)
  6. }
  7.  
  8. func runnable<Ignored>(_ value: Type) -> (Ignored) -> ReturnType {
  9. return { _ in self.method(value) }
  10. }
  11. }
  12.  
  13. extension Functor where Type == Void {
  14. func run() -> ReturnType {
  15. return method(())
  16. }
  17. }
Add Comment
Please, Sign In to add comment