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 bdf81e1184
commit b05e148dc9
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),
}
}
}