1use std::{fmt::Display, ops::Deref};
2
3use crate::{Component, Key, MatchCond, Ref, Value};
4
5type CandidateItem<K, V, R> = (K, V, Component, MatchCond<K, V, R>);
6
7#[derive(Debug, Clone)]
9pub struct Candidate<K, V, R>
10where
11 K: Key,
12 V: Value,
13 R: Ref,
14{
15 values: Vec<CandidateItem<K, V, R>>,
16}
17
18impl<K, V, R> Display for Candidate<K, V, R>
19where
20 K: Key + Display,
21 V: Value + Display,
22 R: Ref + Display,
23{
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 f.write_str("Candidate")?;
26 for (key, value, component, cond) in self.values.iter() {
27 write!(f, "Candidate value: {key} {value} {component} {cond}")?;
28 }
29 Ok(())
30 }
31}
32
33impl<K, V, R> Deref for Candidate<K, V, R>
48where
49 K: Key + Display,
50 V: Value + Display,
51 R: Ref + Display,
52{
53 type Target = Vec<(K, V, Component, MatchCond<K, V, R>)>;
54
55 fn deref(&self) -> &Self::Target {
56 &self.values
57 }
58}
59
60