@@ -230,7 +230,8 @@ pub enum ItemEnum {
230230
231231 Union ( Union ) ,
232232 Struct ( Struct ) ,
233- StructField ( Type ) ,
233+ /// The name of the field is given in the enclosing [`Item`]
234+ Field ( Type ) ,
234235 Enum ( Enum ) ,
235236 Variant ( Variant ) ,
236237
@@ -283,6 +284,7 @@ pub struct Module {
283284pub struct Union {
284285 pub generics : Generics ,
285286 pub fields_stripped : bool ,
287+ /// Will all be [`ItemEnum::Field`]
286288 pub fields : Vec < Id > ,
287289 pub impls : Vec < Id > ,
288290}
@@ -292,6 +294,7 @@ pub struct Struct {
292294 pub kind : StructKind ,
293295 pub generics : Generics ,
294296 pub fields_stripped : bool ,
297+ /// Will all be [`ItemEnum::Field`]
295298 pub fields : Vec < Id > ,
296299 pub impls : Vec < Id > ,
297300}
@@ -300,22 +303,68 @@ pub struct Struct {
300303pub struct Enum {
301304 pub generics : Generics ,
302305 pub variants_stripped : bool ,
306+ /// Will all be [`ItemEnum::Variant`]
303307 pub variants : Vec < Id > ,
304308 pub impls : Vec < Id > ,
305309}
306310
307311#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
308312pub struct Variant {
309313 pub kind : StructKind ,
314+ /// Will all be [`ItemEnum::Field`]
310315 pub fields : Vec < Id > ,
311316 pub fields_stripped : bool ,
312317}
313318
314319#[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
315320#[ serde( rename_all = "snake_case" ) ]
321+ /// The kind used for literals of a struct or enum.
316322pub enum StructKind {
317- Struct ,
323+ /// A "normal" struct, with named fields.
324+ ///
325+ /// Eg:
326+ ///
327+ /// ```rust
328+ /// pub struct A {
329+ /// x: i32,
330+ /// }
331+ /// pub struct B {}
332+ /// pub enum C {
333+ /// Variant { x: i32 },
334+ /// }
335+ /// pub enum D {
336+ /// Variant {},
337+ /// }
338+ /// ```
339+ NamedFields ,
340+ /// Unnamed fields, accessed with a number.
341+ ///
342+ /// Eg:
343+ ///
344+ /// ```rust
345+ /// pub struct A(i32);
346+ /// pub struct B();
347+ /// pub enum C {
348+ /// Variant(i32),
349+ /// }
350+ /// pub enum D {
351+ /// Variant(),
352+ /// }
353+ /// ```
318354 Tuple ,
355+ /// No fields, and no parentheses.
356+ ///
357+ /// Note: Cases without fields but with parentheses will have a different
358+ /// kind, as seen in the examples above.
359+ ///
360+ /// Eg:
361+ ///
362+ /// ```rust
363+ /// pub struct A;
364+ /// pub enum B {
365+ /// Variant,
366+ /// }
367+ /// ```
319368 Unit ,
320369}
321370
0 commit comments