Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn identity(s: &str) -> &str {
- s
- }
- pub fn apply1<F>(v: &str, f: F) -> &str where F: Fn(&str) -> &str {
- f(v)
- }
- pub fn apply2<T, R, F>(v: T, f: F) -> R where F: Fn(T) -> R {
- f(v)
- }
- #[test]
- pub fn test_apply1() {
- assert_eq!("test", apply1("test", identity));
- }
- #[test]
- pub fn test_apply2() {
- assert_eq!("test", apply2("test", identity));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement