fluidattacks-blends-domain 0.40.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use alloc::borrow::ToOwned;

use crate::query::{label_text, match_ast};
use crate::syntax::builders::literal::build_literal_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;

#[expect(
    clippy::unnecessary_wraps,
    reason = "the signature must match the reader dispatch table"
)]
pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let value = match_ast(args.ast_graph, n_id, &["true", "false"], Some(1))
        .into_values()
        .flatten()
        .next()
        .and_then(|value_id| label_text(args.ast_graph, value_id))
        .unwrap_or("")
        .to_owned();
    Ok(Some(build_literal_node(
        args,
        n_id,
        value,
        "bool".to_owned(),
    )))
}