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
//! Deserialization utilities.
use Expr;
use de;
use Error;
use Deserialize;
/// Deserialize into [`Expr`](../struct.Expr.html) and then evaluate using `Expr::eval`.
///
/// # Example
///
/// ```rust
/// #[macro_use]
/// extern crate serde_derive;
/// extern crate toml;
/// extern crate meval;
/// use meval::{Expr, Context};
///
/// #[derive(Deserialize)]
/// struct Foo {
/// #[serde(deserialize_with = "meval::de::as_f64")]
/// x: f64,
/// }
///
/// fn main() {
/// let foo: Foo = toml::from_str(r#" x = "cos(1.)" "#).unwrap();
/// assert_eq!(foo.x, 1f64.cos());
///
/// let foo: Result<Foo, _> = toml::from_str(r#" x = "cos(x)" "#);
/// assert!(foo.is_err());
/// }
/// ```
///
/// See [crate root](../index.html#deserialization) for another example.