Skip to main content

normalize_string_enum_set_selection

Function normalize_string_enum_set_selection 

Source
pub fn normalize_string_enum_set_selection<T>(
    value: &str,
    key: &str,
    item_name: &str,
    authoritative_order: &[T],
    parse: impl Fn(&str) -> Option<T>,
    display: impl Fn(T) -> &'static str,
) -> Result<Vec<&'static str>>
where T: Copy + Eq,
Expand description

Parses and normalizes a string enum set into authoritative order.

This is useful for string_enum_set config values whose storage order should stay stable regardless of the order provided by an API request. The returned values are the canonical storage strings from display.