[][src]Function proc_macro_util::parse_identifier_arrays

pub fn parse_identifier_arrays(
    input: impl IntoIterator<Item = TokenTree>,
    default_span: Span,
    allowed_key_values: &HashMap<&str, &[&str]>
) -> Result<HashMap<String, Vec<String>>, SpanError>

Parse keyed arrays of identifiers.

It expects as an input a parenthesis group, and in this group if it ran into a key in allowed_key_values, then it will parse the following tokens as an array of identifiers.

The values must be in the provided value set.

Arguments

  • input: token iterator to consume
  • default_span: A span that will be used if there is an error that can't be linked to a specific span.
  • allowed_key_values: An hash map to define the allowed keys and their corresponding allowed values.

Return

An hash map with the values found for each keys.

Error

  • When a key is detected but its value is not a bracket group with identifiers separated by commas
  • When an identifier is not in the allowed identifier list for a specific key

Example

  • (not_array, array_key = [value_1, value_2]) Here array_key is defined as a valid key and its following tokens will be processed as an array of identifiers. This will be valid only if both value_1 and value_2 are valid identifiers.