use crate::db::access::{SemanticIndexKeyItemRef, SemanticIndexKeyItemsRef};
#[must_use]
pub(in crate::db) fn index_key_item_order_terms(
key_items: SemanticIndexKeyItemsRef<'_>,
) -> Vec<String> {
match key_items {
SemanticIndexKeyItemsRef::Fields(fields) => fields.to_vec(),
SemanticIndexKeyItemsRef::Accepted(items) => {
canonical_index_order_terms(items.iter().map(|item| item.as_ref()))
}
}
}
fn canonical_index_order_terms<'a, I>(key_items: I) -> Vec<String>
where
I: IntoIterator<Item = SemanticIndexKeyItemRef<'a>>,
{
key_items
.into_iter()
.map(SemanticIndexKeyItemRef::canonical_text)
.collect()
}