diff options
| author | bors <bors@rust-lang.org> | 2014-03-28 00:26:52 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-03-28 00:26:52 -0700 |
| commit | ff64381c8bf6a49a0671287de5f5b7316ae2ef9c (patch) | |
| tree | 8b506d4d1a0fe9b5242ed1ab4817c91890c929c3 /src/libworkcache/lib.rs | |
| parent | 5a68892507cdd42fdf6f1f645d6e38f6f5be67a4 (diff) | |
| parent | f1739b14a1346419a4598339aee32aab07e0d12e (diff) | |
| download | rust-ff64381c8bf6a49a0671287de5f5b7316ae2ef9c.tar.gz rust-ff64381c8bf6a49a0671287de5f5b7316ae2ef9c.zip | |
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
Diffstat (limited to 'src/libworkcache/lib.rs')
| -rw-r--r-- | src/libworkcache/lib.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs index 3e513472027..a049279c5c4 100644 --- a/src/libworkcache/lib.rs +++ b/src/libworkcache/lib.rs @@ -203,7 +203,7 @@ impl Database { self.db_filename.display(), e.to_str()), Ok(r) => { let mut decoder = json::Decoder::new(r); - self.db_cache = Decodable::decode(&mut decoder); + self.db_cache = Decodable::decode(&mut decoder).unwrap(); } } } @@ -252,19 +252,19 @@ enum Work<'a, T> { WorkFromTask(&'a Prep<'a>, Receiver<(Exec, T)>), } -fn json_encode<'a, T:Encodable<json::Encoder<'a>>>(t: &T) -> ~str { +fn json_encode<'a, T:Encodable<json::Encoder<'a>, io::IoError>>(t: &T) -> ~str { let mut writer = MemWriter::new(); let mut encoder = json::Encoder::new(&mut writer as &mut io::Writer); - t.encode(&mut encoder); + let _ = t.encode(&mut encoder); str::from_utf8_owned(writer.unwrap()).unwrap() } // FIXME(#5121) -fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T { +fn json_decode<T:Decodable<json::Decoder, json::Error>>(s: &str) -> T { debug!("json decoding: {}", s); let j = json::from_str(s).unwrap(); let mut decoder = json::Decoder::new(j); - Decodable::decode(&mut decoder) + Decodable::decode(&mut decoder).unwrap() } impl Context { @@ -392,15 +392,15 @@ impl<'a> Prep<'a> { } pub fn exec<'a, T:Send + - Encodable<json::Encoder<'a>> + - Decodable<json::Decoder>>( + Encodable<json::Encoder<'a>, io::IoError> + + Decodable<json::Decoder, json::Error>>( &'a self, blk: proc:Send(&mut Exec) -> T) -> T { self.exec_work(blk).unwrap() } fn exec_work<'a, T:Send + - Encodable<json::Encoder<'a>> + - Decodable<json::Decoder>>( // FIXME(#5121) + Encodable<json::Encoder<'a>, io::IoError> + + Decodable<json::Decoder, json::Error>>( // FIXME(#5121) &'a self, blk: proc:Send(&mut Exec) -> T) -> Work<'a, T> { let mut bo = Some(blk); @@ -443,8 +443,8 @@ impl<'a> Prep<'a> { } impl<'a, T:Send + - Encodable<json::Encoder<'a>> + - Decodable<json::Decoder>> + Encodable<json::Encoder<'a>, io::IoError> + + Decodable<json::Decoder, json::Error>> Work<'a, T> { // FIXME(#5121) pub fn from_value(elt: T) -> Work<'a, T> { |
