From 63fc88757f9742b763114deac75962cb897b8218 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 28 Mar 2013 20:51:40 -0700 Subject: [PATCH] std: remove Encoder::emit_{owned,managed} and Decoder::read_{owned,managed} --- src/libstd/ebml.rs | 14 -------------- src/libstd/json.rs | 4 ---- src/libstd/serialize.rs | 16 +++++----------- src/libsyntax/ext/auto_encode.rs | 4 ---- 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 513897997a5..fccb707ed1f 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -315,16 +315,6 @@ pub mod reader { fn read_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) } // Compound types: - fn read_owned(&self, f: &fn() -> T) -> T { - debug!("read_owned()"); - f() - } - - fn read_managed(&self, f: &fn() -> T) -> T { - debug!("read_managed()"); - f() - } - fn read_enum(&self, name: &str, f: &fn() -> T) -> T { debug!("read_enum(%s)", name); self._check_label(name); @@ -651,10 +641,6 @@ pub mod writer { self.wr_tagged_str(EsStr as uint, v) } - fn emit_borrowed(&self, f: &fn()) { f() } - fn emit_owned(&self, f: &fn()) { f() } - fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, name: &str, f: &fn()) { self._emit_label(name); self.wr_tag(EsEnum as uint, f) diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 373131e9e65..c936f8e4dcd 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -108,10 +108,6 @@ impl serialize::Encoder for Encoder { fn emit_char(&self, v: char) { self.emit_str(str::from_char(v)) } fn emit_str(&self, v: &str) { self.wr.write_str(escape_str(v)) } - fn emit_borrowed(&self, f: &fn()) { f() } - fn emit_owned(&self, f: &fn()) { f() } - fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, _name: &str, f: &fn()) { f() } fn emit_enum_variant(&self, name: &str, _id: uint, cnt: uint, f: &fn()) { // enums are encoded as strings or vectors: diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index daf834dad2e..42a9e24b1cb 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -41,9 +41,6 @@ pub trait Encoder { fn emit_str(&self, v: &str); // Compound types: - fn emit_borrowed(&self, f: &fn()); - fn emit_owned(&self, f: &fn()); - fn emit_managed(&self, f: &fn()); fn emit_enum(&self, name: &str, f: &fn()); fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: &fn()); @@ -97,9 +94,6 @@ pub trait Decoder { fn read_enum_variant(&self, names: &[&str], f: &fn(uint) -> T) -> T; fn read_enum_variant_arg(&self, idx: uint, f: &fn() -> T) -> T; - fn read_owned(&self, f: &fn() -> T) -> T; - fn read_managed(&self, f: &fn() -> T) -> T; - fn read_owned_vec(&self, f: &fn(uint) -> T) -> T; fn read_managed_vec(&self, f: &fn(uint) -> T) -> T; fn read_vec_elt(&self, idx: uint, f: &fn() -> T) -> T; @@ -296,31 +290,31 @@ impl Decodable for () { impl<'self, S:Encoder,T:Encodable> Encodable for &'self T { fn encode(&self, s: &S) { - s.emit_borrowed(|| (**self).encode(s)) + (**self).encode(s) } } impl> Encodable for ~T { fn encode(&self, s: &S) { - s.emit_owned(|| (**self).encode(s)) + (**self).encode(s) } } impl> Decodable for ~T { fn decode(d: &D) -> ~T { - d.read_owned(|| ~Decodable::decode(d)) + ~Decodable::decode(d) } } impl> Encodable for @T { fn encode(&self, s: &S) { - s.emit_managed(|| (**self).encode(s)) + (**self).encode(s) } } impl> Decodable for @T { fn decode(d: &D) -> @T { - d.read_managed(|| @Decodable::decode(d)) + @Decodable::decode(d) } } diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 54f9967e64a..c9357c9d867 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -1242,10 +1242,6 @@ mod test { fn emit_char(&self, +_v: char) { self.add_unknown_to_log(); } fn emit_str(&self, +_v: &str) { self.add_unknown_to_log(); } - fn emit_borrowed(&self, f: &fn()) { self.add_unknown_to_log(); f() } - fn emit_owned(&self, f: &fn()) { self.add_unknown_to_log(); f() } - fn emit_managed(&self, f: &fn()) { self.add_unknown_to_log(); f() } - fn emit_enum(&self, name: &str, f: &fn()) { self.add_to_log(CallToEmitEnum(name.to_str())); f(); }