Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pub enum Variant (FORMAT_VERSION = 20) #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion COMMIT.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b76a012be16de964c242594afba4323997f436b2
065e0b9c9cf3d03f286c5d0b98fbae7185e41b75
33 changes: 30 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::PathBuf;
use serde::{Deserialize, Serialize};

/// rustdoc format-version.
pub const FORMAT_VERSION: u32 = 19;
pub const FORMAT_VERSION: u32 = 20;

/// 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
Expand Down Expand Up @@ -308,9 +308,36 @@ pub struct Enum {
#[serde(rename_all = "snake_case")]
#[serde(tag = "variant_kind", content = "variant_inner")]
pub enum Variant {
/// A variant with no parentheses, and possible discriminant.
///
/// ```rust
/// enum Demo {
/// PlainVariant,
/// PlainWithDiscriminant = 1,
/// }
/// ```
Plain(Option<Discriminant>),
Tuple(Vec<Type>),
Struct(Vec<Id>),
/// A variant with unnamed fields.
///
/// Unlike most of json, `#[doc(hidden)]` fields will be given as `None`
/// instead of being ommited, because order matters.
///
/// ```rust
/// enum Demo {
/// TupleVariant(i32),
/// EmptyTupleVariant(),
/// }
/// ```
Tuple(Vec<Option<Id>>),
/// A variant with named fields.
///
/// ```rust
/// enum Demo {
/// StructVariant { x: i32 },
/// EmptyStructVariant {},
/// }
/// ```
Struct { fields: Vec<Id>, fields_stripped: bool },
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
Expand Down