fluidattacks-blends-domain 0.26.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    query::{adj_ast, label_text},
    syntax::{
        builders::binary_operation::build_binary_operation_node, SyntaxGraphArgs, SyntaxGraphError,
    },
    NodeId,
};
use alloc::borrow::ToOwned;
use alloc::string::String;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    let child_ids = adj_ast(graph, n_id, Some(1), &[]);

    let (operator, left_id, right_id) = if let [left, op, right, ..] = child_ids.as_slice() {
        (
            label_text(graph, *op).unwrap_or("").to_owned(),
            Some(*left),
            Some(*right),
        )
    } else {
        (String::new(), None, None)
    };

    build_binary_operation_node(args, n_id, operator, left_id, right_id).map(Some)
}