The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Serialize Data Structures With Key Value Pairs In Rust

TODO: Pull subtitle into page object
Code
use serde::Serialize;

#[derive(Debug, PartialEq, Serialize)]
#[serde(tag = "type", content = "content", rename_all = "lowercase")]
pub enum Widget {
  Alfa,
  Bravo
}

That will display the type for each element so you can access them by key in (for example) minijinja

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Serialize Data Structures With Key Value Pairs In Rust

Add this to enums:

-- code 
-- rust

use serde::Serialize;

#[derive(Debug, PartialEq, Serialize)]
#[serde(tag = "type", content = "content", rename_all = "lowercase")]
pub enum Widget {
  Alfa,
  Bravo
}

-- p

That will display the type for each element
so you can access them by key in (for example)
minijinja

-- todo

[] talk about the different parts there and the derive stuff
that helps with the basic usage

-- ref
-- title: Serde Enum Representations
-- url: https://serde.rs/enum-representations.html


-- categories
-- Rust
-- Minijinja
-- Serde

-- metadata
-- date: 2023-04-10 16:57:31
-- id: 2ofdqys2
-- site: aws
-- type: post
-- status: draft