1use crate::prelude::*;
2use std::fmt;
3
4#[derive(Clone)]
5pub struct KnowStmt {
6 pub facts: Vec<Fact>,
7 pub line_file: LineFile,
8}
9
10impl KnowStmt {
11 pub fn new(facts: Vec<Fact>, line_file: LineFile) -> Self {
12 KnowStmt { facts, line_file }
13 }
14}
15
16impl fmt::Display for KnowStmt {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 if self.facts.len() == 1 {
19 write!(f, "know {}", self.facts[0])
20 } else {
21 write!(
22 f,
23 "{}{}\n{}",
24 KNOW,
25 COLON,
26 vec_to_string_add_four_spaces_at_beginning_of_each_line(&self.facts, 1),
27 )
28 }
29 }
30}