3
下面的例子不工作时也可以知道,但我想不通为什么:rust_serialize错误:这个值的类型必须在这方面
extern crate rustc_serialize;
use rustc_serialize::json;
fn main() {
let json_str = "{\"foo\": \"bar\"}";
let foo: String = json::decode(&json_str).unwrap().as_object().get("foo").unwrap().as_string().unwrap();
println!("{}", foo);
}
错误:
src/main.rs:8:23: 8:67 error: the type of this value must be known in this context
src/main.rs:8 let foo: String = json::decode(&json_str).unwrap().as_object().get("foo").unwrap().as_string().unwrap();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我至少错误是指在这里错误的位置?