//! Macros for the use in identifiers.

/// Take a `dyn Iterator<Item = &char>` and return a closure that calls `.iter()` and maps
/// the values onto [winnow::error::StrContextValue::CharLiteral].
///
/// # Example
///
/// ```
/// use voa_core::iter_char_context;
/// use winnow::{ModalResult, Parser, combinator::cut_err, token::one_of};
///
/// fn parser(input: &mut &str) -> ModalResult<char> {
///     let accepted_characters = ['a', 'b', 'c'];
///     cut_err(one_of(accepted_characters))
///         .context_with(iter_char_context!(accepted_characters))
///         .parse_next(input)
/// }
///
/// assert!(parser.parse("a").is_ok());
/// ```
#[macro_export]
macro_rules! iter_char_context {
    ($iter:expr) => {
        || {
            use winnow::error::{StrContext, StrContextValue};
            $iter
                .iter()
                .map(|c| StrContext::Expected(StrContextValue::CharLiteral(*c)))
        }
    };
}
