fluidattacks-blends-domain 0.24.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::syntax::builders::pair::build_pair_node;
use crate::syntax::fields::go::keyed_element;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    // Both sides come wrapped in a `literal_element`, whose reader hands back
    // the expression it holds, or the record it stands for when it omits a type.
    let key_id = args.required_field_alt(n_id, keyed_element::KEY)?;
    let value_id = args.required_field_alt(n_id, keyed_element::VALUE)?;
    build_pair_node(args, n_id, key_id, value_id).map(Some)
}