substrate_data/schema/tagged.rs
1//! How a tagged enum's variant keeps what it wraps.
2
3use super::{Schema, Shape};
4
5/// Where a tagged enum's variant keeps what it wraps when that isn't a
6/// struct (`Id(String)` is `{type: "id", value: "…"}`); a wrapped struct's
7/// fields sit next to the tag instead.
8pub const WRAPPED: &str = crate::names::Word::Value.as_str();
9
10/// Whether a tagged enum's variant wrapping `T` lays `T`'s fields next to
11/// the tag (a struct) or keeps `T` under [`WRAPPED`].
12#[doc(hidden)]
13#[must_use]
14pub fn flattens<T: Schema>() -> bool {
15 matches!(T::shape(), Shape::Struct(_))
16}