fluidattacks-blends-domain 0.44.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    syntax::{
        _node_builders::languages::rust::{
            array_expression::build_array_expression, transform::build_syntax_node,
        },
        builders::array_node::build_array_node,
        core_nodes::ArrayExpression,
        readers::rust::generic_reader::generic_reader,
        SyntaxGraphArgs, SyntaxGraphError,
    },
    NodeId,
};
use alloc::vec::Vec;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    generic_reader(
        args,
        n_id,
        |g, n| build_array_expression(g, n, |n| build_syntax_node(g, n)),
        |a, array| match array {
            ArrayExpression::Fixed(fixed) => {
                let c_ids: Vec<NodeId> = fixed.elements.iter().map(|(_, c_id)| *c_id).collect();
                build_array_node(a, n_id, &c_ids, None, None).map(Some)
            }
            ArrayExpression::Repetition(repetition) => build_array_node(
                a,
                n_id,
                &[repetition.element.1],
                None,
                Some(repetition.repetition.1),
            )
            .map(Some),
        },
    )
}