use serde::{Deserialize, Serialize};
/// rustdoc format-version.
-pub const FORMAT_VERSION: u32 = 20;
+pub const FORMAT_VERSION: u32 = 21;
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
/// about the language items in the local crate, as well as info about external items to allow
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Struct {
- pub struct_type: StructType,
+ pub kind: StructKind,
pub generics: Generics,
- pub fields_stripped: bool,
- pub fields: Vec<Id>,
pub impls: Vec<Id>,
}
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum StructKind {
+ /// A struct with no fields and no parentheses.
+ ///
+ /// ```rust
+ /// pub struct Unit;
+ /// ```
+ Unit,
+ /// A struct with unnamed fields.
+ ///
+ /// ```rust
+ /// pub struct TupleStruct(i32);
+ /// pub struct EmptyTupleStruct();
+ /// ```
+ ///
+ /// All [`Id`]'s will point to [`ItemEnum::StructField`]. Private and
+ /// `#[doc(hidden)]` fields will be given as `None`
+ Tuple(Vec<Option<Id>>),
+ /// A struct with nammed fields.
+ ///
+ /// ```rust
+ /// pub struct PlainStruct { x: i32 }
+ /// pub struct EmptyPlainStruct {}
+ /// ```
+ Plain { fields: Vec<Id>, fields_stripped: bool },
+}
+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Enum {
pub generics: Generics,
pub value: String,
}
-#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
-#[serde(rename_all = "snake_case")]
-pub enum StructType {
- Plain,
- Tuple,
- Unit,
-}
-
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Header {
#[serde(rename = "const")]