1
Fork 0

std: change Decoder::read_option to return a generic type

This allows read_option to be used with a custom option type instead
of just core::Option.
This commit is contained in:
Erick Tryzelaar 2013-03-28 13:11:14 -07:00
parent ce9e5ecb6c
commit aa779c1240
3 changed files with 17 additions and 11 deletions

View file

@ -980,10 +980,10 @@ impl<'self> serialize::Decoder for Decoder<'self> {
}
}
fn read_option<T>(&self, f: &fn() -> T) -> Option<T> {
fn read_option<T>(&self, f: &fn(bool) -> T) -> T {
match *self.peek() {
Null => { self.pop(); None }
_ => Some(f()),
Null => { self.pop(); f(false) }
_ => f(true),
}
}
}