Closed
Description
Decoding can fail in the same way as any IO operation or any read_xxx()
function in trait Reader
. So should the serialize::Decodable
trait, no? Otherwise, we again depend on using task::try
for decoding data structures.
My proposal is to change the signature of trait Decodable
to something like:
pub type DecodeResult<T> = Result<T, &str>;
pub trait Decodable<D: Decoder> {
fn decode(d: &mut D) -> DecodeResult<Self>;
}
Likewise, the trait serialize::Decoder
must be changed to return DecodeResult
s as well.
This of course comes with a slight performance penalty in the non-error case.
Metadata
Metadata
Assignees
Labels
No labels