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
use serde::Serialize;
use serde_json::Value;
use std::{
    borrow::Cow,
    collections::HashMap,
    ops::{Deref, DerefMut},
};

/**
A struct for accumulating key-value data for use in handlebars
templates. The values can be any type that is serde serializable
*/
#[derive(Default, Serialize, Debug)]
pub struct Assigns(HashMap<Cow<'static, str>, Value>);

impl Deref for Assigns {
    type Target = HashMap<Cow<'static, str>, Value>;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Assigns {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}