(de: &mut Deserializer)
| 48 | |
| 49 | impl Deserialize for Program { |
| 50 | fn deserialize(de: &mut Deserializer) -> Result<Self> { |
| 51 | let mut program = Program::default(); |
| 52 | de.consume_token_until("<ID> ")?; |
| 53 | let id: usize = de.parse_number()?; |
| 54 | program.id = id; |
| 55 | de.consume_token_until("//<Prompt> ")?; |
| 56 | let combination = de.eat_token_until("\n")?; |
| 57 | let combination: Vec<String> = serde_json::from_str(combination)?; |
| 58 | let combination: Vec<&'static FuncGadget> = combination |
| 59 | .iter() |
| 60 | .map(|func| get_func_gadget(func).unwrap()) |
| 61 | .collect(); |
| 62 | program.combination = combination; |
| 63 | |
| 64 | de.consume_token_until("/*<Combination>:")?; |
| 65 | de.consume_token_until("*/")?; |
| 66 | de.consume_token_until("<Quality> ")?; |
| 67 | let quality = de.consume_token_until("\n")?; |
| 68 | let quality: Quality = serde_json::from_str(quality).unwrap_or_default(); |
| 69 | let statements = de.input.to_string(); |
| 70 | program.statements = statements; |
| 71 | program.set_quality(quality); |
| 72 | Ok(program) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | pub struct Deserializer<'de> { |
nothing calls this directly
no test coverage detected