Skip to main content

native/oxc_ex_nif/src/generated_ast_decoders.rs

// This file is generated by RustQ. Do not edit by hand.

struct ProgramInput<'a> {
    body: Vec<Term<'a>>,
}
fn decode_program_input<'a>(term: Term<'a>) -> NifResult<ProgramInput<'a>> {
    Ok(ProgramInput {
        body: term.map_get(a::body())?.decode::<Vec<Term<'a>>>()?,
    })
}
struct IfStatementInput<'a> {
    test: Term<'a>,
    consequent: Term<'a>,
    alternate: Option<Term<'a>>,
}
fn decode_if_statement_input<'a>(term: Term<'a>) -> R<IfStatementInput<'a>> {
    Ok(IfStatementInput {
        test: term
            .map_get(a::test())
            .map_err(|_| "Missing :test".to_string())?
            .decode::<Term<'a>>()
            .map_err(|_| "Invalid :test".to_string())?,
        consequent: term
            .map_get(a::consequent())
            .map_err(|_| "Missing :consequent".to_string())?
            .decode::<Term<'a>>()
            .map_err(|_| "Invalid :consequent".to_string())?,
        alternate: term
            .map_get(a::alternate())
            .ok()
            .and_then(|t| t.decode::<Term<'a>>().ok()),
    })
}