[−][src]Function serde_lexpr::from_value
pub fn from_value<'a, T>(value: &'a Value) -> Result<T> where
T: Deserialize<'a>,
Interpret a lexpr::Value
as an instance of type T
.
This conversion can fail if the structure of the Value
does not match the
structure expected by T
, for example if T
is a struct type but the
Value
contains something other than a S-expression list. It can also fail
if the structure is correct but T
's implementation of Deserialize
decides that something is wrong with the data, for example required struct
fields are missing from the S-expression map or some number is too big to
fit in the expected primitive type.
let val = Value::string("foo"); let s: String = serde_lexpr::from_value(&val).unwrap(); assert_eq!("foo", s);