diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-08-31 14:00:29 +0300 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-09-20 20:07:54 +0300 |
| commit | fc363cb482f92851b48b46402b5b5117627a840e (patch) | |
| tree | 3fcb17d93a2ee42b2dc266c486e1c651260fa393 /src/libserialize | |
| parent | 91e7239db40372027a642bdbda19a6d593155a9f (diff) | |
| download | rust-fc363cb482f92851b48b46402b5b5117627a840e.tar.gz rust-fc363cb482f92851b48b46402b5b5117627a840e.zip | |
rustc_metadata: go only through rustc_serialize in astencode.
Diffstat (limited to 'src/libserialize')
| -rw-r--r-- | src/libserialize/lib.rs | 3 | ||||
| -rw-r--r-- | src/libserialize/serialize.rs | 44 |
2 files changed, 1 insertions, 46 deletions
diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index ebd93912097..7082ee5d292 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -45,8 +45,7 @@ Core encoding and decoding interfaces. extern crate rustc_unicode; extern crate collections; -pub use self::serialize::{Decoder, Encoder, Decodable, Encodable, - DecoderHelpers, EncoderHelpers}; +pub use self::serialize::{Decoder, Encoder, Decodable, Encodable}; pub use self::serialize::{SpecializationError, SpecializedEncoder, SpecializedDecoder}; pub use self::serialize::{UseSpecializedEncodable, UseSpecializedDecodable}; diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 4414fee7878..ba6eefe82bb 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -594,50 +594,6 @@ impl<T:Decodable+Send+Sync> Decodable for Arc<T> { } // ___________________________________________________________________________ -// Helper routines - -pub trait EncoderHelpers: Encoder { - fn emit_from_vec<T, F>(&mut self, v: &[T], f: F) - -> Result<(), Self::Error> - where F: FnMut(&mut Self, &T) -> Result<(), Self::Error>; -} - -impl<S:Encoder> EncoderHelpers for S { - fn emit_from_vec<T, F>(&mut self, v: &[T], mut f: F) -> Result<(), S::Error> where - F: FnMut(&mut S, &T) -> Result<(), S::Error>, - { - self.emit_seq(v.len(), |this| { - for (i, e) in v.iter().enumerate() { - this.emit_seq_elt(i, |this| { - f(this, e) - })?; - } - Ok(()) - }) - } -} - -pub trait DecoderHelpers: Decoder { - fn read_to_vec<T, F>(&mut self, f: F) - -> Result<Vec<T>, Self::Error> where - F: FnMut(&mut Self) -> Result<T, Self::Error>; -} - -impl<D: Decoder> DecoderHelpers for D { - fn read_to_vec<T, F>(&mut self, mut f: F) -> Result<Vec<T>, D::Error> where F: - FnMut(&mut D) -> Result<T, D::Error>, - { - self.read_seq(|this, len| { - let mut v = Vec::with_capacity(len); - for i in 0..len { - v.push(this.read_seq_elt(i, |this| f(this))?); - } - Ok(v) - }) - } -} - -// ___________________________________________________________________________ // Specialization-based interface for multi-dispatch Encodable/Decodable. /// Implement this trait on your `{Encodable,Decodable}::Error` types |
