Skip to content

Instantly share code, notes, and snippets.

@killerswan
Created September 1, 2012 04:51
Show Gist options
  • Save killerswan/3564072 to your computer and use it in GitHub Desktop.
Save killerswan/3564072 to your computer and use it in GitHub Desktop.
help me understand implicit copyability
./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);
^~~~~~~~~~~
#!/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