Guest User

Rust errors W/generics

a guest
Jun 5th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. CODE:
  2. fn map<T, U>(v: [T], f: fn(T) -> U) -> [U] {
  3. let mut acc = [];
  4. for v.each {|elt| acc += [f(elt)]; }
  5. acc
  6. }
  7.  
  8. ERRORS:
  9. arguments.rs:17:8: 17:14 error: attempted access of field each on type ['a], but no public field or method with that name was found
  10. arguments.rs:17 for v.each {|elt| acc += [f(elt)]; }
  11. ^~~~~~
  12. arguments.rs:17:8: 17:40 error: the type of this value must be known in this context
  13. arguments.rs:17 for v.each {|elt| acc += [f(elt)]; }
  14. ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertisement
Add Comment
Please, Sign In to add comment