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:
parent
ce9e5ecb6c
commit
aa779c1240
3 changed files with 17 additions and 11 deletions
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue