summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-11-22 14:39:32 +0100
committerMichael Woerister <michaelwoerister@posteo>2017-11-28 13:03:39 +0100
commit687e099b441ff62d6ab69577e28e0eebfa82a186 (patch)
tree2f69e5be22701d79edee47c7bef4df3ff90d3b1b /src/librustc_data_structures
parent8fbc91cfe1fecfd8534b1b828bb64806a67d9659 (diff)
downloadrust-687e099b441ff62d6ab69577e28e0eebfa82a186.tar.gz
rust-687e099b441ff62d6ab69577e28e0eebfa82a186.zip
incr.comp.: Make a bunch of query results encodable.
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/indexed_set.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index c5ffb003399..cb80f602a1c 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -17,6 +17,7 @@ use std::slice;
 use bitslice::{BitSlice, Word};
 use bitslice::{bitwise, Union, Subtract, Intersect};
 use indexed_vec::Idx;
+use rustc_serialize;
 
 /// Represents a set (or packed family of sets), of some element type
 /// E, where each E is identified by some unique index type `T`.
@@ -35,6 +36,26 @@ impl<T: Idx> Clone for IdxSetBuf<T> {
     }
 }
 
+impl<T: Idx> rustc_serialize::Encodable for IdxSetBuf<T> {
+    fn encode<E: rustc_serialize::Encoder>(&self,
+                                     encoder: &mut E)
+                                     -> Result<(), E::Error> {
+        self.bits.encode(encoder)
+    }
+}
+
+impl<T: Idx> rustc_serialize::Decodable for IdxSetBuf<T> {
+    fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<IdxSetBuf<T>, D::Error> {
+        let words: Vec<Word> = rustc_serialize::Decodable::decode(d)?;
+
+        Ok(IdxSetBuf {
+            _pd: PhantomData,
+            bits: words,
+        })
+    }
+}
+
+
 // pnkfelix wants to have this be `IdxSet<T>([Word]) and then pass
 // around `&mut IdxSet<T>` or `&IdxSet<T>`.
 //