compose-idents 0.3.0

A Rust macro for generating new identifiers (names of variables, functions, traits, etc) by concatenating one or more arbitrary parts and applying other manipulations.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::ast::AliasSpecItem;
use crate::core::Environment;
use crate::error::Error;
use crate::eval::{Context, Eval, Evaluated};
use std::collections::HashMap;

impl Eval for AliasSpecItem {
    fn eval(&self, environment: &Environment, context: &mut Context) -> Result<Evaluated, Error> {
        let evaluated_value = self.value().eval(environment, context)?;

        let mut bindings = HashMap::new();
        context.add_variable(self.alias().ident(), evaluated_value.clone());
        bindings.insert(self.alias(), evaluated_value);

        Ok(Evaluated::Bindings(bindings))
    }
}