Created
September 1, 2012 04:51
-
-
Save killerswan/3564072 to your computer and use it in GitHub Desktop.
help me understand implicit copyability
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
| ./pp.rs:12:14: 12:25 warning: instantiating copy type parameter with a not implicitly copyable type | |
| ./pp.rs:12 let data = result::get(result_data); | |
| ^~~~~~~~~~~ |
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
| #!/usr/bin/env rustx | |
| use std; | |
| import std::json; | |
| import std::json::Json; | |
| import std::json::Error; | |
| fn main (args: ~[~str]) { | |
| if vec::len(args) != 2 { io::println(~"Usage: ./pp.rs JSON-FILE"); return; } | |
| let result_data: Result<~str, ~str> = io::read_whole_file_str(&path::Path(args[1])); | |
| let data = result::get(result_data); | |
| // ^~~~~~~~~~~ result::unwrap, however, uses a move and doesn't give this warning | |
| let result_json: Result<Json, Error> = json::from_str(data); | |
| let json = result::get(result_json); | |
| io::println(json::to_str_pretty(json)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment