mathlex 0.4.1

Mathematical expression parser for LaTeX and plain text notation, producing a language-agnostic AST
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Helpers for collecting mathematical constants from an expression tree.

use crate::ast::{ExprKind, Expression, MathConstant};
use std::collections::HashSet;

use super::walker::for_each_child;

pub(super) fn cc_core(expr: &Expression, cs: &mut HashSet<MathConstant>) {
    if let ExprKind::Constant(c) = &expr.kind {
        cs.insert(*c);
    }
    for_each_child(expr, |child| cc_core(child, cs));
}