mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
ac7ba99209
Add `TypeId` methods `variants` `fields` `field` for `type_info` Tracking issue rust-lang/rust#146922 - Adds `fn TypeId::variants` returns the number of variants, for struct and union and primitive types, it's always 1. - Adds `fn TypeId::fields` returns the number of fields. - Adds `fn TypeId::field` returns a field representing type `FieldId`. - Adds a new type `FieldId`, which is a wrapper of `FieldRepresentingType`'s `TypeId`. For methods `{fields,field}`, if indexing out of bounds, a compile-time error will be raised. Regarding the removal of `Type` items, this will be done in a later PR in one go. r? @oli-obk