fluidattacks-blends-domain 0.40.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::alloc::borrow::ToOwned;
use crate::syntax::_node_builders::core::SyntaxNodeBuildError;
use crate::syntax::core_nodes::{CoreSyntaxNode, CoreSyntaxNodeWithId};
use alloc::vec::Vec;

pub fn filter_comments(items: Vec<CoreSyntaxNodeWithId>) -> Vec<CoreSyntaxNodeWithId> {
    items
        .into_iter()
        .filter(|(n, _)| !matches!(n, CoreSyntaxNode::Comment(_)))
        .collect()
}
pub fn ensure_one_expression(
    element_group: &[CoreSyntaxNodeWithId],
) -> Result<CoreSyntaxNodeWithId, SyntaxNodeBuildError> {
    match element_group {
        [unique] => Ok(unique.clone()),
        [_, ..] => Err(SyntaxNodeBuildError::Error(
            "There is more than one expression/node for an element of an ArrayExpression"
                .to_owned(),
        )),
        [] => Err(SyntaxNodeBuildError::Error(
            "An element group of an ArrayExpression is empty".to_owned(),
        )),
    }
}