Skip to main content

deserialize

Function deserialize 

Source
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where T: DeserializeOwned + 'static, D: Deserializer<'de>,
Expand description

Deserialize a value from a singleton map.

This is the counterpart to serialize, deserializing from the singleton map format back to the original type.

ยงExamples

use noyalib::with::singleton_map;

#[derive(serde::Deserialize, serde::Serialize, PartialEq, Debug)]
enum Status { Active }

#[derive(serde::Deserialize, Debug)]
struct Doc {
    #[serde(with = "singleton_map")]
    s: Status,
}

let d: Doc = noyalib::from_str("s:\n  Active: null\n").unwrap();
assert_eq!(d.s, Status::Active);