SHARE
TWEET

Untitled

a guest Mar 26th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub fn identity(s: &str) -> &str {
  2.     s
  3. }
  4.  
  5. pub fn apply1<F>(v: &str, f: F) -> &str where F: Fn(&str) -> &str {
  6.     f(v)
  7. }
  8.  
  9. pub fn apply2<T, R, F>(v: T, f: F) -> R where F: Fn(T) -> R {
  10.     f(v)
  11. }
  12.  
  13. #[test]
  14. pub fn test_apply1() {
  15.     assert_eq!("test", apply1("test", identity));
  16. }
  17.  
  18. #[test]
  19. pub fn test_apply2() {
  20.      assert_eq!("test", apply2("test", identity));
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top