srdf/matcher.rs
1pub struct Any;
2
3pub trait Matcher<T>: PartialEq<T> {
4 fn value(&self) -> Option<T>;
5}
6
7impl<T> Matcher<T> for Any {
8 fn value(&self) -> Option<T> {
9 None
10 }
11}
12
13impl<T> PartialEq<T> for Any {
14 fn eq(&self, _other: &T) -> bool {
15 true
16 }
17}
18
19// pub enum Matcher<R: Rdf> {
20// Variable(String),
21// Term(R::Term),
22// }
23
24// impl<R: Rdf> PartialEq for Matcher<R> {
25// fn eq(&self, other: &Self) -> bool {
26// match (self, other) {
27// (Matcher::Variable(_), _) | (_, Matcher::Variable(_)) => true,
28// (Matcher::Term(t1), Matcher::Term(t2)) => t1 == t2,
29// }
30// }
31// }
32
33// impl<R: Rdf> From<Any> for Matcher<R> {
34// #[inline]
35// fn from(_value: Any) -> Self {
36// Matcher::Variable("_".to_string())
37// }
38// }
39
40// impl<I, R> From<I> for Matcher<R>
41// where
42// R: Rdf,
43// I: Into<R::Term>,
44// I: Clone, // TODO: check this
45// {
46// fn from(value: I) -> Self {
47// Matcher::Term(value.into())
48// }
49// }
50
51// impl<R: Rdf> std::fmt::Display for Matcher<R> {
52// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53// match self {
54// Matcher::Variable(var) => write!(f, "?{}", var),
55// Matcher::Term(term) => write!(f, "{}", term),
56// }
57// }
58// }