Skip to main content

serialize

Function serialize 

Source
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where T: Serialize, S: Serializer,
Expand description

Serialize a value with recursive singleton map transformation.

This applies singleton map formatting to all enum variants throughout the nested structure.

ยงExamples

use noyalib::with::singleton_map_recursive;

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

#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct Task {
    #[serde(with = "singleton_map_recursive")]
    statuses: Vec<Status>,
}