pddl_core/pretty_print/
predicate.rs1use std::ops::Deref;
4
5use crate::pretty_print::{sealed, PrettyRenderer};
6use crate::types::{ActionSymbol, DurativeActionSymbol, Predicate, PreferenceName};
7use crate::visitor::{Accept, Visitor};
8use pretty::RcDoc;
9
10impl sealed::Sealed for Predicate {}
11impl sealed::Sealed for ActionSymbol {}
12impl sealed::Sealed for DurativeActionSymbol {}
13impl sealed::Sealed for PreferenceName {}
14
15impl Visitor<Predicate, RcDoc<'static>> for PrettyRenderer {
16 fn visit(&self, value: &Predicate) -> RcDoc<'static> {
17 value.deref().accept(self)
18 }
19}
20
21impl Visitor<ActionSymbol, RcDoc<'static>> for PrettyRenderer {
22 fn visit(&self, value: &ActionSymbol) -> RcDoc<'static> {
23 value.deref().accept(self)
24 }
25}
26
27impl Visitor<DurativeActionSymbol, RcDoc<'static>> for PrettyRenderer {
28 fn visit(&self, value: &DurativeActionSymbol) -> RcDoc<'static> {
29 value.deref().accept(self)
30 }
31}
32
33impl Visitor<PreferenceName, RcDoc<'static>> for PrettyRenderer {
34 fn visit(&self, value: &PreferenceName) -> RcDoc<'static> {
35 value.deref().accept(self)
36 }
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42 use crate::pretty_print::prettify;
43 use crate::visitor::Accept;
44 use assert2::check;
45
46 #[test]
47 fn predicate_works() {
48 let x = Predicate::new_string("at");
49 check!(prettify!(x, 10) == "at");
50 }
51
52 #[test]
53 fn action_symbol_works() {
54 let x = ActionSymbol::new_string("mov-B");
55 check!(prettify!(x, 10) == "mov-B");
56 }
57}