diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-15 09:06:06 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-15 12:20:47 -0800 |
| commit | c9ea7c9a58bc2bcfe77d264cedaeca5a3296634a (patch) | |
| tree | 31c2d7bf5821f59511938a9080fab250fe5c59d1 /src/librbml | |
| parent | ef0bc464af110d24d4663fbe51eca3646a897308 (diff) | |
| download | rust-c9ea7c9a58bc2bcfe77d264cedaeca5a3296634a.tar.gz rust-c9ea7c9a58bc2bcfe77d264cedaeca5a3296634a.zip | |
serialize: Change some FnOnce bounds to FnMut
Relax some of the bounds on the decoder methods back to FnMut to help accomodate some more flavorful variants of decoders which may need to run the closure more than once when it, for example, attempts to find the first successful enum to decode. This a breaking change due to the bounds for the trait switching, and clients will need to update from `FnOnce` to `FnMut` as well as likely making the local function binding mutable in order to call the function. [breaking-change]
Diffstat (limited to 'src/librbml')
| -rw-r--r-- | src/librbml/lib.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 28d5e1812f0..bbedbc75395 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -499,8 +499,9 @@ pub mod reader { Ok(result) } - fn read_enum_variant<T, F>(&mut self, _: &[&str], f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder<'doc>, uint) -> DecodeResult<T>, + fn read_enum_variant<T, F>(&mut self, _: &[&str], + mut f: F) -> DecodeResult<T> + where F: FnMut(&mut Decoder<'doc>, uint) -> DecodeResult<T>, { debug!("read_enum_variant()"); let idx = try!(self._next_uint(EsEnumVid)); @@ -526,8 +527,9 @@ pub mod reader { f(self) } - fn read_enum_struct_variant<T, F>(&mut self, _: &[&str], f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder<'doc>, uint) -> DecodeResult<T>, + fn read_enum_struct_variant<T, F>(&mut self, _: &[&str], + mut f: F) -> DecodeResult<T> + where F: FnMut(&mut Decoder<'doc>, uint) -> DecodeResult<T>, { debug!("read_enum_struct_variant()"); let idx = try!(self._next_uint(EsEnumVid)); @@ -610,8 +612,8 @@ pub mod reader { self.read_tuple_arg(idx, f) } - fn read_option<T, F>(&mut self, f: F) -> DecodeResult<T> where - F: FnOnce(&mut Decoder<'doc>, bool) -> DecodeResult<T>, + fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where + F: FnMut(&mut Decoder<'doc>, bool) -> DecodeResult<T>, { debug!("read_option()"); self.read_enum("Option", move |this| { |
