use encode_list_with with safe_encode_bits func

This commit is contained in:
Kasey White
2022-05-23 12:20:04 -04:00
parent c38da6426f
commit 344620136f
2 changed files with 12 additions and 3 deletions

View File

@@ -137,10 +137,14 @@ impl Encoder {
}
}
pub fn encode_list_with<T: Encode>(&mut self, list: Vec<T>) -> Result<(), String> {
pub fn encode_list_with(
&mut self,
encoder_func: for<'r> fn(u8, &'r mut Encoder) -> Result<(), String>,
list: Vec<u8>,
) -> Result<(), String> {
for item in list {
self.one();
self.encode(item)?;
encoder_func(item, self)?;
}
self.zero();
Ok(())