From 687e099b441ff62d6ab69577e28e0eebfa82a186 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 22 Nov 2017 14:39:32 +0100 Subject: incr.comp.: Make a bunch of query results encodable. --- src/librustc_data_structures/indexed_set.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/librustc_data_structures') 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 Clone for IdxSetBuf { } } +impl rustc_serialize::Encodable for IdxSetBuf { + fn encode(&self, + encoder: &mut E) + -> Result<(), E::Error> { + self.bits.encode(encoder) + } +} + +impl rustc_serialize::Decodable for IdxSetBuf { + fn decode(d: &mut D) -> Result, D::Error> { + let words: Vec = rustc_serialize::Decodable::decode(d)?; + + Ok(IdxSetBuf { + _pd: PhantomData, + bits: words, + }) + } +} + + // pnkfelix wants to have this be `IdxSet([Word]) and then pass // around `&mut IdxSet` or `&IdxSet`. // -- cgit 1.4.1-3-g733a5