add tests for case and constr

Fix a minor issue with decoding order
This commit is contained in:
microproofs
2023-09-02 21:25:34 -04:00
committed by Kasey
parent c9b01ab365
commit 819a0a20e6
8 changed files with 67 additions and 22 deletions

View File

@@ -182,6 +182,21 @@ impl<'b> Decoder<'b> {
Ok(vec_array)
}
pub fn decode_list_with_debug<T, F>(
&mut self,
decoder_func: F,
state_log: &mut Vec<String>,
) -> Result<Vec<T>, Error>
where
F: Copy + FnOnce(&mut Decoder, &mut Vec<String>) -> Result<T, Error>,
{
let mut vec_array: Vec<T> = Vec::new();
while self.bit()? {
vec_array.push(decoder_func(self, state_log)?)
}
Ok(vec_array)
}
/// Decode the next bit in the buffer.
/// If the bit was 0 then return true.
/// Otherwise return false.