credence_lib/render/catalog/
columns.rs

1use {compris::normal::*, kutil_std::collections::*};
2
3//
4// ExtraColumns
5//
6
7/// Extra columns.
8pub type ExtraColumns<'own> = FastHashMap<&'own str, RefValuePath<'own>>;
9
10/// Flatten extra columns.
11pub fn flatten_columns(columns: Option<&Map>) -> ExtraColumns<'_> {
12    let mut flat_columns = FastHashMap::<&str, _>::new();
13
14    if let Some(columns) = columns {
15        for (key, value) in columns {
16            if let Value::Text(key) = key {
17                if let Some(value_path) = to_ref_value_path(value) {
18                    flat_columns.insert(&key.value, value_path);
19                }
20            }
21        }
22    }
23
24    flat_columns
25}