datalog_structural_model/position/
head_path.rs1use std::fmt;
4
5use super::index::{HeadAtomIndex, HeadDisjunctIndex};
6
7#[derive(
10 Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
11)]
12#[serde(deny_unknown_fields)]
13pub struct HeadAtomPath {
14 disjunct: HeadDisjunctIndex,
15 atom: HeadAtomIndex,
16}
17
18impl HeadAtomPath {
19 #[must_use]
21 pub const fn new(disjunct: HeadDisjunctIndex, atom: HeadAtomIndex) -> Self {
22 Self { disjunct, atom }
23 }
24
25 #[must_use]
27 pub const fn atomic() -> Self {
28 Self::new(HeadDisjunctIndex::new(0), HeadAtomIndex::new(0))
29 }
30
31 #[must_use]
33 pub const fn disjunct(self) -> HeadDisjunctIndex {
34 self.disjunct
35 }
36
37 #[must_use]
39 pub const fn atom(self) -> HeadAtomIndex {
40 self.atom
41 }
42}
43
44impl fmt::Display for HeadAtomPath {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 write!(
47 f,
48 "head disjunct {} atom {}",
49 self.disjunct.get(),
50 self.atom.get()
51 )
52 }
53}