1#[macro_export]
2macro_rules! as_inference_fact_impl {
3 ($IM:ident, $IF: ident) => {
4 impl AsFact<$IM, $IF> for $IF {
5 fn as_fact(&self, _model: &$IM) -> Result<boow::Bow<$IF>> {
6 Ok(boow::Bow::Borrowed(self))
7 }
8 }
9
10 impl AsFact<$IM, $IF> for &str {
11 fn as_fact(&self, model: &$IM) -> Result<boow::Bow<$IF>> {
12 Ok(boow::Bow::Owned($IF::new(model, self)?))
13 }
14 }
15
16 impl AsFact<$IM, $IF> for () {
17 fn as_fact(&self, model: &$IM) -> Result<boow::Bow<$IF>> {
18 Ok(boow::Bow::Owned($IF::new(model, "")?))
19 }
20 }
21
22 impl AsFact<$IM, $IF> for Option<&str> {
23 fn as_fact(&self, model: &$IM) -> Result<boow::Bow<$IF>> {
24 if let Some(it) = self {
25 Ok(boow::Bow::Owned($IF::new(model, it)?))
26 } else {
27 Ok(boow::Bow::Owned($IF::new(model, "")?))
28 }
29 }
30 }
31 };
32}
33
34#[macro_export]
35macro_rules! as_fact_impl {
36 ($M:ident, $F: ident) => {
37 impl AsFact<$M, $F> for $F {
38 fn as_fact(&self, _model: &$M) -> Result<boow::Bow<$F>> {
39 Ok(boow::Bow::Borrowed(self))
40 }
41 }
42
43 impl AsFact<$M, $F> for &str {
44 fn as_fact(&self, model: &$M) -> Result<boow::Bow<$F>> {
45 Ok(boow::Bow::Owned($F::new(model, self)?))
46 }
47 }
48 };
49}