rust/src/test/ui/autobind.rs

13 lines
342 B
Rust
Raw Normal View History

// run-pass
2014-09-14 22:27:36 -05:00
fn f<T>(x: Vec<T>) -> T { return x.into_iter().next().unwrap(); }
fn g<F>(act: F) -> isize where F: FnOnce(Vec<isize>) -> isize { return act(vec![1, 2, 3]); }
pub fn main() {
assert_eq!(g(f), 1);
2015-01-02 16:32:54 -06:00
let f1 = f;
assert_eq!(f1(vec!["x".to_string(), "y".to_string(), "z".to_string()]),
"x".to_string());
}