| 1 | use synrust-analyzer cargo syn 1.0.109 crate/::{ |
| 2 | selfrust-analyzer cargo syn 1.0.109 crate/, Attributerust-analyzer cargo syn 1.0.109 attr/Attribute#, Datarust-analyzer cargo syn 1.0.109 derive/Data#, DeriveInputrust-analyzer cargo syn 1.0.109 derive/DeriveInput#, Fieldrust-analyzer cargo syn 1.0.109 data/Field# as SynFieldrust-analyzer cargo syn 1.0.109 data/Field#, Fieldsrust-analyzer cargo syn 1.0.109 data/Fields# as SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#, Genericsrust-analyzer cargo syn 1.0.109 generics/Generics#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, |
| 3 | Typerust-analyzer cargo syn 1.0.109 ty/Type#, Visibilityrust-analyzer cargo syn 1.0.109 data/Visibility#, |
| 4 | }; |
| 5 | |
| 6 | use quoterust-analyzer cargo quote 1.0.47 crate/::ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#; |
| 7 | |
| 8 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#; |
| 9 | |
| 10 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#}; |
| 11 | |
| 12 | mod field_maprust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/; |
| 13 | |
| 14 | pub use selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/::field_maprust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/::FieldMaprust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/field_map/FieldMap#; |
| 15 | |
| 16 | ////////////////////////////////////////////////////////////////////////////// |
| 17 | |
| 18 | /// A type definition(enum,struct,union). |
| 19 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 20 | pub struct DataStructurerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#<'a> { |
| 21 | pub visrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#vis.: &'a Visibilityrust-analyzer cargo syn 1.0.109 data/Visibility#, |
| 22 | pub namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#name.: &'a Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, |
| 23 | pub genericsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#generics.: &'a Genericsrust-analyzer cargo syn 1.0.109 generics/Generics#, |
| 24 | pub attrsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#attrs.: &'a [Attributerust-analyzer cargo syn 1.0.109 attr/Attribute#], |
| 25 | |
| 26 | /// Whether this is a struct/union/enum. |
| 27 | pub data_variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#data_variant.: DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#, |
| 28 | |
| 29 | /// The variants in the type definition. |
| 30 | /// |
| 31 | /// If it is a struct or a union this only has 1 element. |
| 32 | pub variantsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#variants.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#<'a>>, |
| 33 | } |
| 34 | |
| 35 | impl<'a> DataStructurerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#<'a> { |
| 36 | pub fn newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`DataStructure<'a>`]new().(ast: &'a DeriveInputrust-analyzer cargo syn 1.0.109 derive/DeriveInput#) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`DataStructure<'a>`] { |
| 37 | let name = &ast.identrust-analyzer cargo syn 1.0.109 derive/DeriveInput#ident.; |
| 38 | |
| 39 | let data_variant: DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#; |
| 40 | |
| 41 | let mut variants = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 42 | |
| 43 | match &ast.datarust-analyzer cargo syn 1.0.109 derive/DeriveInput#data. { |
| 44 | Datarust-analyzer cargo syn 1.0.109 derive/Data#::Enumrust-analyzer cargo syn 1.0.109 derive/Data#Enum#(enum_) => { |
| 45 | for (variant, var) in enum_.variantsrust-analyzer cargo syn 1.0.109 derive/DataEnum#variants..iterrust-analyzer cargo syn 1.0.109 punctuated/impl#[`Punctuated<T, P>`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 46 | variants.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#::newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]new().( |
| 47 | StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams# { |
| 48 | variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#variant.: variant, |
| 49 | namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#name.: &var.identrust-analyzer cargo syn 1.0.109 data/Variant#ident., |
| 50 | }, |
| 51 | &var.fieldsrust-analyzer cargo syn 1.0.109 data/Variant#fields., |
| 52 | )); |
| 53 | } |
| 54 | data_variant = DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#::Enumrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Enum#; |
| 55 | } |
| 56 | Datarust-analyzer cargo syn 1.0.109 derive/Data#::Structrust-analyzer cargo syn 1.0.109 derive/Data#Struct#(struct_) => { |
| 57 | variants.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#::newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]new().( |
| 58 | StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams# { |
| 59 | variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#variant.: 0, |
| 60 | namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#name.: name, |
| 61 | }, |
| 62 | &struct_.fieldsrust-analyzer cargo syn 1.0.109 derive/DataStruct#fields., |
| 63 | )); |
| 64 | data_variant = DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#::Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Struct#; |
| 65 | } |
| 66 | |
| 67 | Datarust-analyzer cargo syn 1.0.109 derive/Data#::Unionrust-analyzer cargo syn 1.0.109 derive/Data#Union#(union_) => { |
| 68 | let fields = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&union_.fieldsrust-analyzer cargo syn 1.0.109 derive/DataUnion#fields..namedrust-analyzer cargo syn 1.0.109 data/FieldsNamed#named.); |
| 69 | let sk = StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Bracedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Braced#; |
| 70 | let vari = Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#::with_fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]with_fields().( |
| 71 | StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams# { |
| 72 | variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#variant.: 0, |
| 73 | namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#name.: name, |
| 74 | }, |
| 75 | sk, |
| 76 | fields, |
| 77 | ); |
| 78 | variants.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(vari); |
| 79 | data_variant = DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#::Unionrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Union#; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`DataStructure<'a>`] { |
| 84 | visrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#vis.: &ast.visrust-analyzer cargo syn 1.0.109 derive/DeriveInput#vis., |
| 85 | namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#name., |
| 86 | attrsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#attrs.: &ast.attrsrust-analyzer cargo syn 1.0.109 derive/DeriveInput#attrs., |
| 87 | genericsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#generics.: &ast.genericsrust-analyzer cargo syn 1.0.109 derive/DeriveInput#generics., |
| 88 | data_variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#data_variant., |
| 89 | variantsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataStructure#variants., |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | ////////////////////////////////////////////////////////////////////////////// |
| 95 | |
| 96 | /// Whether the struct is tupled or not. |
| 97 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 98 | pub enum StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind# { |
| 99 | /// structs declared using the `struct Name( ... ) syntax. |
| 100 | Tupledrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Tupled#, |
| 101 | /// structs declared using the `struct Name{ ... }` or `struct name;` syntaxes |
| 102 | Bracedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Braced#, |
| 103 | } |
| 104 | |
| 105 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 106 | pub enum DataVariantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant# { |
| 107 | Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Struct#, |
| 108 | Enumrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Enum#, |
| 109 | Unionrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/DataVariant#Union#, |
| 110 | } |
| 111 | |
| 112 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 113 | pub struct FieldIndexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex# { |
| 114 | pub variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#variant.: usize, |
| 115 | pub posrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#pos.: usize, |
| 116 | } |
| 117 | |
| 118 | ////////////////////////////////////////////////////////////////////////////// |
| 119 | |
| 120 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 121 | struct StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#<'a> { |
| 122 | variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#variant.: usize, |
| 123 | namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#name.: &'a Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, |
| 124 | } |
| 125 | |
| 126 | /// A struct/union or a variant of an enum. |
| 127 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 128 | pub struct Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#<'a> { |
| 129 | /// The name of this `Struct`. |
| 130 | /// |
| 131 | /// If this is a struct/union:these is the same as DataStructure.name. |
| 132 | /// |
| 133 | /// If this is an enum:this is the name of the variant. |
| 134 | pub namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#name.: &'a Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, |
| 135 | pub kindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#kind.: StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#, |
| 136 | pub fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#fields.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'a>>, |
| 137 | _privrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#_priv.: (), |
| 138 | } |
| 139 | |
| 140 | impl<'a> Structrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#<'a> { |
| 141 | fn newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]new().(p: StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#<'a>, fields: &'a SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`] { |
| 142 | let kind = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().fields { |
| 143 | SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#::Namedrust-analyzer cargo syn 1.0.109 data/Fields#Named# { .. } => StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Bracedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Braced#, |
| 144 | SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#::Unnamedrust-analyzer cargo syn 1.0.109 data/Fields#Unnamed# { .. } => StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Tupledrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Tupled#, |
| 145 | SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#::Unitrust-analyzer cargo syn 1.0.109 data/Fields#Unit# { .. } => StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#::Bracedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#Braced#, |
| 146 | }; |
| 147 | let fields = match fields { |
| 148 | SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#::Namedrust-analyzer cargo syn 1.0.109 data/Fields#Named#(f) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&f.namedrust-analyzer cargo syn 1.0.109 data/FieldsNamed#named.), |
| 149 | SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#::Unnamedrust-analyzer cargo syn 1.0.109 data/Fields#Unnamed#(f) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&f.unnamedrust-analyzer cargo syn 1.0.109 data/FieldsUnnamed#unnamed.), |
| 150 | SynFieldsrust-analyzer cargo syn 1.0.109 data/Fields#::Unitrust-analyzer cargo syn 1.0.109 data/Fields#Unit# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 151 | }; |
| 152 | |
| 153 | Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]::with_fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]with_fields().(p, kind, fields) |
| 154 | } |
| 155 | |
| 156 | fn with_fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`]with_fields().<I>(p: StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#<'a>, kind: StructKindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructKind#, fields: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<I>) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`] |
| 157 | where |
| 158 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = &'a SynFieldrust-analyzer cargo syn 1.0.109 data/Field#>, |
| 159 | { |
| 160 | let fields = match fields { |
| 161 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) => Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#::from_iterrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]from_iter().(p, x), |
| 162 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 163 | }; |
| 164 | |
| 165 | Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Struct<'a>`] { |
| 166 | namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#name.: p.namerust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#name., |
| 167 | kindrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#kind., |
| 168 | fieldsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#fields., |
| 169 | _privrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Struct#_priv.: (), |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | ////////////////////////////////////////////////////////////////////////////// |
| 175 | |
| 176 | /// Represent a struct field |
| 177 | /// |
| 178 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 179 | pub struct Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'a> { |
| 180 | pub indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#index.: FieldIndexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#, |
| 181 | pub attrsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#attrs.: &'a [Attributerust-analyzer cargo syn 1.0.109 attr/Attribute#], |
| 182 | /// identifier for the field,which is either an index(in a tuple struct) or a name. |
| 183 | pub identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#ident.: FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#<'a>, |
| 184 | pub pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#pattern_ident.: Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, |
| 185 | pub tyrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#ty.: &'a Typerust-analyzer cargo syn 1.0.109 ty/Type#, |
| 186 | } |
| 187 | |
| 188 | impl<'a> Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#<'a> { |
| 189 | fn newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]new().(index: FieldIndexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#, field: &'a SynFieldrust-analyzer cargo syn 1.0.109 data/Field#) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`] { |
| 190 | let span; |
| 191 | let ident = match field.identrust-analyzer cargo syn 1.0.109 data/Field#ident..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 192 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident) => { |
| 193 | span = ident.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(); |
| 194 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::Namedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Named#(ident) |
| 195 | } |
| 196 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 197 | span = synrust-analyzer cargo syn 1.0.109 crate/::spannedrust-analyzer cargo syn 1.0.109 spanned/::Spannedrust-analyzer cargo syn 1.0.109 spanned/Spanned#::spanrust-analyzer cargo syn 1.0.109 spanned/impl#[T][Spanned]span().(&field.tyrust-analyzer cargo syn 1.0.109 data/Field#ty.); |
| 198 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::new_indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`FieldIdent<'a>`]new_index().(index.posrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#pos.) |
| 199 | } |
| 200 | }; |
| 201 | let pattern_ident = Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("f{}_7ac4rtizw8q", ident), span); |
| 202 | |
| 203 | Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`] { |
| 204 | indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#index., |
| 205 | attrsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#attrs.: &field.attrsrust-analyzer cargo syn 1.0.109 data/Field#attrs., |
| 206 | identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#ident., |
| 207 | pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#pattern_ident., |
| 208 | tyrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#ty.: &field.tyrust-analyzer cargo syn 1.0.109 data/Field#ty., |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /// Gets the identifier of this field as an `&Ident`. |
| 213 | pub fn pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]pattern_ident().(&self) -> &Identrust-analyzer cargo proc-macro2 1.0.107 Ident# { |
| 214 | &self.pattern_identrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#pattern_ident. |
| 215 | } |
| 216 | |
| 217 | fn from_iterrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]from_iter().<I>(p: StructParamsrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#<'a>, fields: I) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]> |
| 218 | where |
| 219 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = &'a SynFieldrust-analyzer cargo syn 1.0.109 data/Field#>, |
| 220 | { |
| 221 | fields |
| 222 | .into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().() |
| 223 | .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 224 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(pos, f)| { |
| 225 | let fi = FieldIndexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex# { |
| 226 | variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#variant.: p.variantrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/StructParams#variant., |
| 227 | posrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIndex#pos., |
| 228 | }; |
| 229 | Fieldrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/Field#::newrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`Field<'a>`]new().(fi, f) |
| 230 | }) |
| 231 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | ////////////////////////////////////////////////////////////////////////////// |
| 236 | |
| 237 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 238 | pub enum FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#<'a> { |
| 239 | Indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Index#(usize), |
| 240 | Namedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Named#(&'a Identrust-analyzer cargo proc-macro2 1.0.107 Ident#), |
| 241 | } |
| 242 | |
| 243 | impl<'a> Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#<'a> { |
| 244 | fn fmtrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`FieldIdent<'a>`][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 245 | match self { |
| 246 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::Indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Index#(x) => Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/num/imp/impl#[usize][Display]fmt().(x, f), |
| 247 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::Namedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Named#(x) => Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`&T`][Display]fmt().(x, f), |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | impl<'a> ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens# for FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#<'a> { |
| 253 | fn to_tokensrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`FieldIdent<'a>`][ToTokens]to_tokens().(&self, tokens: &mut TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#) { |
| 254 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 255 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::Indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Index#(ind) => synrust-analyzer cargo syn 1.0.109 crate/::Indexrust-analyzer cargo syn 1.0.109 expr/Index#::fromrust-analyzer cargo syn 1.0.109 expr/impl#[Index][`From<usize>`]from().(ind).to_tokensrust-analyzer cargo syn 1.0.109 expr/printing/impl#[Index][ToTokens]to_tokens().(tokens), |
| 256 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::Namedrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Named#(name) => name.to_tokensrust-analyzer cargo quote 1.0.47 to_tokens/impl#[Ident][ToTokens]to_tokens().(tokens), |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | impl<'a> FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#<'a> { |
| 262 | fn new_indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`FieldIdent<'a>`]new_index().(index: usize) -> Selfrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/impl#[`FieldIdent<'a>`] { |
| 263 | FieldIdentrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#::Indexrust-analyzer cargo const_format_proc_macros 0.2.34 datastructure/FieldIdent#Index#(index) |
| 264 | } |
| 265 | } |