/// Parses a WebAssembly element component from the input.
///
/// See <https://webassembly.github.io/spec/core/binary/modules.html#element-section>
Parses a WebAssembly element component from the input.
See
Parses a WebAssembly element component from the input . See
pub fn parse_element(input: &[u8]) -> IResult<&[u8], Element> {
    alt((
        map(
            preceded(
                match_byte(0x00),
                tuple((parse_expression, parse_vector(parse_u32))),
            ),
            |(offset, functions)| {
                Element::active(
                    0,
                    offset,
                    ReferenceType::Function,
                    functions.to_initializers(),
                )
            },
        ),
        map(
            preceded(
                match_byte(0x01),
                preceded(match_byte(0x00), parse_vector(parse_u32)),
            ),
            |functions| Element::passive(ReferenceType::Function, functions.to_initializers()),
        ),
        map(
            preceded(
                match_byte(0x02),
                tuple((
                    parse_u32,
                    parse_expression,
                    preceded(match_byte(0x00), parse_vector(parse_u32)),
                )),
            ),
            |(table, offset, functions)| {
                Element::active(
                    table,
                    offset,
                    ReferenceType::Function,
                    functions.to_initializers(),
                )
            },
        ),
        map(
            preceded(
                match_byte(0x03),
                preceded(match_byte(0x00), parse_vector(parse_u32)),
            ),
            |functions| Element::declarative(ReferenceType::Function, functions.to_initializers()),
        ),
        map(
            preceded(
                match_byte(0x04),
                tuple((parse_expression, parse_vector(parse_expression))),
            ),
            |(offset, initializers)| {
                Element::active(0, offset, ReferenceType::Function, initializers)
            },
        ),
        map(
            preceded(
                match_byte(0x05),
                tuple((parse_reference_type, parse_vector(parse_expression))),
            ),
            |(kind, initializers)| Element::passive(kind, initializers),
        ),
        map(
            preceded(
                match_byte(0x06),
                tuple((
                    parse_u32,
                    parse_expression,
                    parse_reference_type,
                    parse_vector(parse_expression),
                )),
            ),
            |(table, offset, kind, initializers)| {
                Element::active(table, offset, kind, initializers)
            },
        ),
        map(
            preceded(
                match_byte(0x07),
                tuple((parse_reference_type, parse_vector(parse_expression))),
            ),
            |(kind, initializers)| Element::declarative(kind, initializers),
        ),
    ))(input)
}
pub fn parse_element ( input : & [ u8 ] ) -> IResult < & [ u8 ] , Element > { alt ( ( map ( preceded ( match_byte ( 0x00 ) , tuple ( ( parse_expression , parse_vector ( parse_u32 ) ) ) , ) , | ( offset , functions ) | { Element :: active ( 0 , offset , ReferenceType :: Function , functions . to_initializers ( ) , ) } , ) , map ( preceded ( match_byte ( 0x01 ) , preceded ( match_byte ( 0x00 ) , parse_vector ( parse_u32 ) ) , ) , | functions | Element :: passive ( ReferenceType :: Function , functions . to_initializers ( ) ) , ) , map ( preceded ( match_byte ( 0x02 ) , tuple ( ( parse_u32 , parse_expression , preceded ( match_byte ( 0x00 ) , parse_vector ( parse_u32 ) ) , ) ) , ) , | ( table , offset , functions ) | { Element :: active ( table , offset , ReferenceType :: Function , functions . to_initializers ( ) , ) } , ) , map ( preceded ( match_byte ( 0x03 ) , preceded ( match_byte ( 0x00 ) , parse_vector ( parse_u32 ) ) , ) , | functions | Element :: declarative ( ReferenceType :: Function , functions . to_initializers ( ) ) , ) , map ( preceded ( match_byte ( 0x04 ) , tuple ( ( parse_expression , parse_vector ( parse_expression ) ) ) , ) , | ( offset , initializers ) | { Element :: active ( 0 , offset , ReferenceType :: Function , initializers ) } , ) , map ( preceded ( match_byte ( 0x05 ) , tuple ( ( parse_reference_type , parse_vector ( parse_expression ) ) ) , ) , | ( kind , initializers ) | Element :: passive ( kind , initializers ) , ) , map ( preceded ( match_byte ( 0x06 ) , tuple ( ( parse_u32 , parse_expression , parse_reference_type , parse_vector ( parse_expression ) , ) ) , ) , | ( table , offset , kind , initializers ) | { Element :: active ( table , offset , kind , initializers ) } , ) , map ( preceded ( match_byte ( 0x07 ) , tuple ( ( parse_reference_type , parse_vector ( parse_expression ) ) ) , ) , | ( kind , initializers ) | Element :: declarative ( kind , initializers ) , ) , ) ) ( input ) }
Parses a WebAssembly element component from the input.
Parses a WebAssembly element component from the input .
input
&[u8]