【发布时间】:2013-07-18 14:57:59
【问题描述】:
我正在学习 Rust 以及 extra::json 模块。这是我的示例(带有额外的不需要的类型注释):
let j:Result<Json,JsonError> = from_str("[{\"bar\":\"baz\", \"biz\":123}]");
let l:List = match j {
Ok(List(l)) => l,
Ok(_) => fail!("Expected a list at the top level"),
Err(e) => fail!(fmt!("Error: %?", e))
};
println(fmt!("item = %?", l.iter().advance(|i|{
match i {
&Object(o) => {
println(fmt!("Object is %?", o));
},
_ => {
fail!("Should be a list of objects, no?");
}
}
println(fmt!("i=%?", i));
true
})));
当我编译时,我得到了这个:
$ rust run json.rs
json.rs:70:9: 70:18 error: cannot move out of dereference of & pointer
json.rs:70 &Object(o) => {
^~~~~~~~~
note: in expansion of fmt!
json.rs:68:10: 79:6 note: expansion site
error: aborting due to previous error
我有 other examples 使用没有遇到此错误的匹配。
感谢您的帮助!
【问题讨论】: