pub struct RankedItem<'a, T> {
pub item: &'a T,
pub index: usize,
pub rank: Ranking,
pub ranked_value: Cow<'a, str>,
pub key_index: usize,
pub key_threshold: Option<Ranking>,
}Expand description
An item annotated with its ranking information.
Produced during the ranking phase of the match-sorting pipeline and
passed to sorting functions (both the default three-level comparator and
custom base_sort / sorter overrides).
§Type Parameters
'a- Lifetime of the reference to the original item in the input slice.T- The item type being ranked.
§Examples
use std::borrow::Cow;
use matchsorter::{RankedItem, Ranking};
let item = "hello".to_owned();
let ranked = RankedItem {
item: &item,
index: 0,
rank: Ranking::CaseSensitiveEqual,
ranked_value: Cow::Borrowed("hello"),
key_index: 0,
key_threshold: None,
};
assert_eq!(ranked.rank, Ranking::CaseSensitiveEqual);
assert_eq!(*ranked.item, "hello");Fields§
§item: &'a TReference to the original item in the input slice.
index: usizeOriginal index of the item in the input slice, used for stable sort tie-breaking.
rank: RankingThe ranking score representing how well the item matched the query.
ranked_value: Cow<'a, str>The string value (from one of the item’s keys) that produced the best match against the query. Borrowed in no-keys mode (zero-copy from the input slice) and owned in keys mode.
key_index: usizeIndex of the winning key-value pair in the flattened key-values list. Lower values indicate keys declared earlier in the keys array.
key_threshold: Option<Ranking>Per-key threshold override from the winning key, or None if the
key uses the global threshold.
Trait Implementations§
Source§impl<'a, T: Clone> Clone for RankedItem<'a, T>
impl<'a, T: Clone> Clone for RankedItem<'a, T>
Source§fn clone(&self) -> RankedItem<'a, T>
fn clone(&self) -> RankedItem<'a, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more