SHARE
TWEET

Untitled

a guest Aug 24th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn take_vec<T>(_v: Vec<T>) {} // requires a Vec
  2.  
  3. fn main() {
  4.     // collect returns any kind of collection
  5.     let x = [1, 2, 3].into_iter().collect();
  6.     // the type of x is not determined yet
  7.    
  8.     take_vec(x); // now x has to be a Vec
  9.     // if you remove this line, this fails to compile because it does not know what type x should be
  10. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top