substrate-data 0.3.1

One data model, text syntax, binary form, packed frames and schema system — for any program's files, saves and wire messages.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! How a tagged enum's variant keeps what it wraps.

use super::{Schema, Shape};

/// Where a tagged enum's variant keeps what it wraps when that isn't a
/// struct (`Id(String)` is `{type: "id", value: "…"}`); a wrapped struct's
/// fields sit next to the tag instead.
pub const WRAPPED: &str = crate::names::Word::Value.as_str();

/// Whether a tagged enum's variant wrapping `T` lays `T`'s fields next to
/// the tag (a struct) or keeps `T` under [`WRAPPED`].
#[doc(hidden)]
#[must_use]
pub fn flattens<T: Schema>() -> bool {
    matches!(T::shape(), Shape::Struct(_))
}