1
use crate::ast::ReturnType;
2
use polyquine::Quine;
3
use serde::{Deserialize, Serialize};
4
use std::fmt::{Debug, Display};
5
use std::hash::Hash;
6
use uniplate::derive_unplateable;
7

            
8
derive_unplateable!(Metadata);
9

            
10
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default, Quine)]
11
#[path_prefix(conjure_cp::ast)]
12
pub struct Metadata {
13
    pub clean: bool,
14
    pub etype: Option<ReturnType>,
15
}
16

            
17
impl Metadata {
18
2467712
    pub fn new() -> Metadata {
19
2467712
        Metadata {
20
4852521
            clean: false,
21
4852521
            etype: None,
22
4852521
        }
23
4852521
    }
24
2384809

            
25
2392489
    pub fn clone_dirty(&self) -> Metadata {
26
2392489
        Metadata {
27
7680
            clean: false,
28
7680
            ..self.clone()
29
7680
        }
30
7680
    }
31
}
32

            
33
impl Display for Metadata {
34
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35
        write!(f, "Metadata")
36
7296
    }
37
7296
}
38
7296

            
39
7296
impl Hash for Metadata {
40
7296
    fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
41
        // Dummy method - Metadata is ignored when hashing an Expression
42
    }
43
}