Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn take_vec<T>(_v: Vec<T>) {} // requires a Vec
- fn main() {
- // collect returns any kind of collection
- let x = [1, 2, 3].into_iter().collect();
- // the type of x is not determined yet
- take_vec(x); // now x has to be a Vec
- // if you remove this line, this fails to compile because it does not know what type x should be
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement