auto merge of #13107 : seanmonstar/rust/encoder-errors, r=erickt
All of Decoder and Encoder's methods now return a Result. Encodable.encode() and Decodable.decode() return a Result as well. fixes #12292
This commit is contained in:
commit
ff64381c8b
27 changed files with 6558 additions and 1419 deletions
|
|
@ -15,12 +15,12 @@ extern crate serialize;
|
|||
|
||||
use serialize::{json, Decodable};
|
||||
|
||||
trait JD : Decodable<json::Decoder> { }
|
||||
trait JD : Decodable<json::Decoder, json::Error> { }
|
||||
|
||||
fn exec<T: JD>() {
|
||||
let doc = json::from_str("").unwrap();
|
||||
let mut decoder = json::Decoder::new(doc);
|
||||
let _v: T = Decodable::decode(&mut decoder);
|
||||
let _v: T = Decodable::decode(&mut decoder).unwrap();
|
||||
fail!()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ use serialize::{json, Decodable};
|
|||
pub fn main() {
|
||||
let json = json::from_str("[1]").unwrap();
|
||||
let mut decoder = json::Decoder::new(json);
|
||||
let _x: Vec<int> = Decodable::decode(&mut decoder);
|
||||
let _x: Vec<int> = Decodable::decode(&mut decoder).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue