Created
March 17, 2014 07:06
-
-
Save Havvy/9595118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main () { | |
| use std::vec_ng::Vec; | |
| let mut a_vec: Vec<int> = Vec::new(); | |
| a_vec.push(0); | |
| a_vec.push(1); | |
| a_vec.push(2); | |
| let a_str: ~str; | |
| a_str = a_vec.map(|n| -> ~str { | |
| n.to_str() | |
| }).concat(); | |
| println!("{}", a_str); | |
| let b_str: ~str; | |
| b_str = a_vec.iter().map(|n| -> ~str { | |
| n.to_str() | |
| }).concat(); | |
| println!("{}", b_str); | |
| } | |
| /* | |
| [vm:test]$ rustc src/iter.rs --out-dir bin | |
| src/iter.rs:11:13: 13:7 warning: use of deprecated item: Use `xs.iter().map(closure)` instead., #[warn(deprecated)] on by default | |
| src/iter.rs:11 a_str = a_vec.map(|n| -> ~str { | |
| src/iter.rs:12 n.to_str() | |
| src/iter.rs:13 }).concat(); | |
| src/iter.rs:19:13: 21:16 error: type `std::iter::Map<,&int,~str,std::vec::Items<,int>>` does not implement any method in scope named `concat` | |
| src/iter.rs:19 b_str = a_vec.iter().map(|n| -> ~str { | |
| src/iter.rs:20 n.to_str() | |
| src/iter.rs:21 }).concat(); | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment