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
48
49
50
51
//! `gtmpl_value` is a basic implementation for internal values within
//! [`gtmpl-rust`][gtmpl_value-github]. It is used as to represent values parsed from
//! the template and from the context.
//!
//! [gtmpl_value-github]: https://github.com/fiji-flo/gtmpl-rust
//!
//! The [`From`](https://doc.rust-lang.org/std/convert/trait.From.html) trait is
//! implemented for:
//!
//! * `String, &str`
//! * most numeric types `u64, u32, …, i64, i32, …, f64, f32`
//! * `bool`
//! * `Vec<Value>, &[Value]`
//! * `HashMap<String, Value>`
//!
//! [`gtmpl_derive`](https://github.com/fiji-flo/gtmpl_derive) provides a custom
//! `derive` for structs.
//!
//! # Examples
//!
//! ```rust
//! extern crate gtmpl_value;
//! use gtmpl_value::Value;
//!
//! fn main() {
//!     let v: Value = "something".into();
//!     println!("{}", v);
//! }
//! ```

mod from;
mod number;
mod value;

pub use from::*;
pub use value::*;

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_function_cmp() {
        fn f(a: &[Value]) -> Result<Value, String> {
            Ok(a[0].clone())
        };
        let f1 = Function { f: f };
        let f2 = Function { f: f };
        assert_eq!(f1, f2);
    }
}