conjure_core/
metadata.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::ast::types::ReturnType;
use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display};
use uniplate::{derive_unplateable, Biplate, Uniplate};

derive_unplateable!(Metadata);

#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
pub struct Metadata {
    pub clean: bool,
    pub etype: Option<ReturnType>,
}

impl Metadata {
    pub fn new() -> Metadata {
        Metadata {
            clean: false,
            etype: None,
        }
    }

    pub fn clone_dirty(&self) -> Metadata {
        Metadata {
            clean: false,
            ..self.clone()
        }
    }
}

impl Display for Metadata {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "Metadata")
    }
}

// impl<T> Display for Metadata<T> where T: for<'a> MetadataKind<'a> {
//     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
//         write!(f, "Metadata")
//     }
// }

//
// impl<T> Metadata<T> where T: for<'a> MetadataKind<'a> {
//     fn new(a: T) -> Metadata<T> {
//         Metadata { a }
//     }
// }