extern crate serde_json;
use serde_json::Value;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let filepath = "./map/test/anhui.txt";
match File::open(filepath) {
Err(why) => println!("Open file failed : {:?}", why.kind()),
Ok(mut file) => {
let mut content: String = String::new();
file.read_to_string(&mut content);
println!("{}", &mut content);
serde_json::from_str(&mut content);
}
}
}
错误信息:
error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [--explain E0282]
--> src/main.rs:16:17
|>
16 |> serde_json::from_str(&mut content);
|> ^^^^^^^^^^^^^^^^^^^^