Skip to content

Commit 7c556ad

Browse files
committed
Merge pull request #19887 from alexcrichton/serialize-fn-mut
serialize: Change some FnOnce bounds to FnMut Reviewed-by: brson
2 parents eb73345 + c9ea7c9 commit 7c556ad

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/librbml/lib.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,9 @@ pub mod reader {
499499
Ok(result)
500500
}
501501

502-
fn read_enum_variant<T, F>(&mut self, _: &[&str], f: F) -> DecodeResult<T> where
503-
F: FnOnce(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
502+
fn read_enum_variant<T, F>(&mut self, _: &[&str],
503+
mut f: F) -> DecodeResult<T>
504+
where F: FnMut(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
504505
{
505506
debug!("read_enum_variant()");
506507
let idx = try!(self._next_uint(EsEnumVid));
@@ -526,8 +527,9 @@ pub mod reader {
526527
f(self)
527528
}
528529

529-
fn read_enum_struct_variant<T, F>(&mut self, _: &[&str], f: F) -> DecodeResult<T> where
530-
F: FnOnce(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
530+
fn read_enum_struct_variant<T, F>(&mut self, _: &[&str],
531+
mut f: F) -> DecodeResult<T>
532+
where F: FnMut(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
531533
{
532534
debug!("read_enum_struct_variant()");
533535
let idx = try!(self._next_uint(EsEnumVid));
@@ -610,8 +612,8 @@ pub mod reader {
610612
self.read_tuple_arg(idx, f)
611613
}
612614

613-
fn read_option<T, F>(&mut self, f: F) -> DecodeResult<T> where
614-
F: FnOnce(&mut Decoder<'doc>, bool) -> DecodeResult<T>,
615+
fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where
616+
F: FnMut(&mut Decoder<'doc>, bool) -> DecodeResult<T>,
615617
{
616618
debug!("read_option()");
617619
self.read_enum("Option", move |this| {

src/libserialize/json.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -2082,8 +2082,9 @@ impl ::Decoder<DecoderError> for Decoder {
20822082
f(self)
20832083
}
20842084

2085-
fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) -> DecodeResult<T> where
2086-
F: FnOnce(&mut Decoder, uint) -> DecodeResult<T>,
2085+
fn read_enum_variant<T, F>(&mut self, names: &[&str],
2086+
mut f: F) -> DecodeResult<T>
2087+
where F: FnMut(&mut Decoder, uint) -> DecodeResult<T>,
20872088
{
20882089
debug!("read_enum_variant(names={})", names);
20892090
let name = match self.pop() {
@@ -2133,7 +2134,7 @@ impl ::Decoder<DecoderError> for Decoder {
21332134
}
21342135

21352136
fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> DecodeResult<T> where
2136-
F: FnOnce(&mut Decoder, uint) -> DecodeResult<T>,
2137+
F: FnMut(&mut Decoder, uint) -> DecodeResult<T>,
21372138
{
21382139
debug!("read_enum_struct_variant(names={})", names);
21392140
self.read_enum_variant(names, f)
@@ -2230,8 +2231,8 @@ impl ::Decoder<DecoderError> for Decoder {
22302231
self.read_tuple_arg(idx, f)
22312232
}
22322233

2233-
fn read_option<T, F>(&mut self, f: F) -> DecodeResult<T> where
2234-
F: FnOnce(&mut Decoder, bool) -> DecodeResult<T>,
2234+
fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where
2235+
F: FnMut(&mut Decoder, bool) -> DecodeResult<T>,
22352236
{
22362237
debug!("read_option()");
22372238
match self.pop() {

src/libserialize/serialize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ pub trait Decoder<E> {
120120
F: FnOnce(&mut Self) -> Result<T, E>;
121121

122122
fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, E> where
123-
F: FnOnce(&mut Self, uint) -> Result<T, E>;
123+
F: FnMut(&mut Self, uint) -> Result<T, E>;
124124
fn read_enum_variant_arg<T, F>(&mut self, a_idx: uint, f: F) -> Result<T, E> where
125125
F: FnOnce(&mut Self) -> Result<T, E>;
126126

127127
fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, E> where
128-
F: FnOnce(&mut Self, uint) -> Result<T, E>;
128+
F: FnMut(&mut Self, uint) -> Result<T, E>;
129129
fn read_enum_struct_variant_field<T, F>(&mut self,
130130
&f_name: &str,
131131
f_idx: uint,
@@ -154,7 +154,7 @@ pub trait Decoder<E> {
154154

155155
// Specialized types:
156156
fn read_option<T, F>(&mut self, f: F) -> Result<T, E> where
157-
F: FnOnce(&mut Self, bool) -> Result<T, E>;
157+
F: FnMut(&mut Self, bool) -> Result<T, E>;
158158

159159
fn read_seq<T, F>(&mut self, f: F) -> Result<T, E> where
160160
F: FnOnce(&mut Self, uint) -> Result<T, E>;

0 commit comments

Comments
 (0)