1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::io::Cursor;
use crate::compact1::Operations;
use crate::{Error, Result, Tape};
index! {
#[doc = "A dictionary index."]
pub Dictionaries
}
impl Dictionaries {
#[inline]
pub fn get(&self, index: usize) -> Result<Operations> {
debug_assert!(index < self.len());
Cursor::new(&self[index]).take()
}
}
impl TryFrom<&Dictionaries> for Vec<Operations> {
type Error = Error;
fn try_from(dictionatires: &Dictionaries) -> Result<Self> {
let mut values = Vec::with_capacity(dictionatires.len());
for index in 0..dictionatires.len() {
values.push(Dictionaries::get(dictionatires, index)?);
}
Ok(values)
}
}