| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 2 | |
| 3 | use quoterust-analyzer cargo quote 1.0.47 crate/::{format_identrust-analyzer cargo quote 1.0.47 format/format_ident!, quoterust-analyzer cargo quote 1.0.47 quote!}; |
| 4 | use synrust-analyzer cargo syn 2.0.119 crate/::{Datarust-analyzer cargo syn 2.0.119 derive/Data#, DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Pathrust-analyzer cargo syn 2.0.119 path/Path#, Typerust-analyzer cargo syn 2.0.119 ty/Type#}; |
| 5 | |
| 6 | use superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::{ |
| 7 | modelsrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/::{FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttribute#, FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttributeBuilder#, TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttributeBuilder#}, |
| 8 | TraitHandlerMultiplerust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandlerMultiple#, |
| 9 | }; |
| 10 | use craterust-analyzer cargo educe 0.6.0 crate/::{panicrust-analyzer cargo educe 0.6.0 panic/, Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#}; |
| 11 | |
| 12 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct IntoEnumHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/into/into_enum/IntoEnumHandler#; |
| 13 | |
| 14 | impl TraitHandlerMultiplerust-analyzer cargo educe 0.6.0 trait_handlers/TraitHandlerMultiple# for IntoEnumHandlerrust-analyzer cargo educe 0.6.0 trait_handlers/into/into_enum/IntoEnumHandler# { |
| 15 | #[inline] |
| 16 | fn trait_meta_handlerrust-analyzer cargo educe 0.6.0 trait_handlers/into/into_enum/impl#[IntoEnumHandler][TraitHandlerMultiple]trait_meta_handler().( |
| 17 | ast: &DeriveInputrust-analyzer cargo syn 2.0.119 derive/DeriveInput#, |
| 18 | token_stream: &mut proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, |
| 19 | traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#], |
| 20 | meta: &[Metarust-analyzer cargo syn 2.0.119 attr/Meta#], |
| 21 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<()> { |
| 22 | let type_attribute = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttributeBuilder# { |
| 23 | enable_typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttributeBuilder#enable_types.: true |
| 24 | } |
| 25 | .build_from_into_metarust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/impl#[TypeAttributeBuilder]build_from_into_meta().(meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | |
| 27 | if let Datarust-analyzer cargo syn 2.0.119 derive/Data#::Enumrust-analyzer cargo syn 2.0.119 derive/Data#Enum#(data) = &ast.datarust-analyzer cargo syn 2.0.119 derive/DeriveInput#data. { |
| 28 | let field_attributes: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<usize, FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttribute#>> = { |
| 29 | let mut map = 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().(); |
| 30 | |
| 31 | for variant in data.variantsrust-analyzer cargo syn 2.0.119 derive/DataEnum#variants..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().() { |
| 32 | let mut field_map = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 33 | |
| 34 | let _ = TypeAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttributeBuilder# { |
| 35 | enable_typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttributeBuilder#enable_types.: false |
| 36 | } |
| 37 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/impl#[TypeAttributeBuilder]build_from_attributes().(&variant.attrsrust-analyzer cargo syn 2.0.119 data/Variant#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 38 | |
| 39 | for (index, field) in variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields..iterrust-analyzer cargo syn 2.0.119 data/impl#[Fields]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 40 | let field_attribute = FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttributeBuilder# { |
| 41 | enable_typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttributeBuilder#enable_types.: true |
| 42 | } |
| 43 | .build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().(&field.attrsrust-analyzer cargo syn 2.0.119 data/Field#attrs., traits)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 44 | |
| 45 | for ty in field_attribute.typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttribute#types..keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().() { |
| 46 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().type_attribute.typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttribute#types..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(ty) { |
| 47 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/::no_into_implrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/no_into_impl().(ty)); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | field_map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(index, field_attribute); |
| 52 | } |
| 53 | |
| 54 | map.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(field_map); |
| 55 | } |
| 56 | |
| 57 | map |
| 58 | }; |
| 59 | |
| 60 | for (target_ty, bound) in type_attribute.typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/type_attribute/TypeAttribute#types. { |
| 61 | let mut into_types: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&Typerust-analyzer cargo syn 2.0.119 ty/Type#> = 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().(); |
| 62 | |
| 63 | let mut arms_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 64 | |
| 65 | type Variantsrust-analyzer cargo educe 0.6.0 trait_handlers/into/into_enum/Variants#<'a> = |
| 66 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&'a Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, bool, usize, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, &'a Typerust-analyzer cargo syn 2.0.119 ty/Type#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a Pathrust-analyzer cargo syn 2.0.119 path/Path#>)>; |
| 67 | |
| 68 | let mut variants: Variantsrust-analyzer cargo educe 0.6.0 trait_handlers/into/into_enum/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().(); |
| 69 | |
| 70 | for (variant, field_attributes) in data.variantsrust-analyzer cargo syn 2.0.119 derive/DataEnum#variants..iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(field_attributes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 71 | { |
| 72 | if let Fieldsrust-analyzer cargo syn 2.0.119 data/Fields#::Unitrust-analyzer cargo syn 2.0.119 data/Fields#Unit# = &variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields. { |
| 73 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::trait_not_support_unit_variantrust-analyzer cargo educe 0.6.0 panic/trait_not_support_unit_variant().( |
| 74 | meta[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().().get_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]get_ident().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 75 | variant, |
| 76 | )); |
| 77 | } |
| 78 | |
| 79 | let (index, field, method) = { |
| 80 | let fields = &variant.fieldsrust-analyzer cargo syn 2.0.119 data/Variant#fields.; |
| 81 | |
| 82 | if fields.lenrust-analyzer cargo syn 2.0.119 data/impl#[Fields]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 83 | let field = fields.into_iterrust-analyzer cargo syn 2.0.119 data/impl#[`&'a Fields`][IntoIterator]into_iter().().nextrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Iter<'a, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 84 | |
| 85 | let method = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(field_attribute) = field_attributes.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&0) { |
| 86 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(method) = field_attribute.typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttribute#types..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&target_ty) { |
| 87 | method.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 88 | } else { |
| 89 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 90 | } |
| 91 | } else { |
| 92 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 93 | }; |
| 94 | |
| 95 | (0usize, field, method) |
| 96 | } else { |
| 97 | let mut into_field: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, &Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Pathrust-analyzer cargo syn 2.0.119 path/Path#>)> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 98 | |
| 99 | for (index, field) in fields.iterrust-analyzer cargo syn 2.0.119 data/impl#[Fields]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 100 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(field_attribute) = field_attributes.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&index) { |
| 101 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((key, method)) = |
| 102 | field_attribute.typesrust-analyzer cargo educe 0.6.0 trait_handlers/into/models/field_attribute/FieldAttribute#types..get_key_valuerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_key_value().(&target_ty) |
| 103 | { |
| 104 | if into_field.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 105 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/::multiple_into_fieldsrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/multiple_into_fields().(key)); |
| 106 | } |
| 107 | |
| 108 | into_field = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((index, field, method.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().())); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | if into_field.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 114 | // search the same type |
| 115 | for (index, field) in fields.iterrust-analyzer cargo syn 2.0.119 data/impl#[Fields]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 116 | let field_ty = superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/into/common/::to_hash_typerust-analyzer cargo educe 0.6.0 trait_handlers/into/common/to_hash_type().(&field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty.); |
| 117 | |
| 118 | if target_ty.eqrust-analyzer cargo educe 0.6.0 common/tools/hash_type/impl#[HashType][`PartialEq<Self>`]eq().(&field_ty) { |
| 119 | if into_field.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 120 | // multiple candidates |
| 121 | into_field = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 122 | |
| 123 | break; |
| 124 | } |
| 125 | |
| 126 | into_field = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((index, field, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)); |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(into_field) = into_field { |
| 132 | into_field |
| 133 | } else { |
| 134 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/::no_into_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/no_into_field().(&target_ty)); |
| 135 | } |
| 136 | } |
| 137 | }; |
| 138 | |
| 139 | let (field_name, is_tuple): (Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, bool) = match field.identrust-analyzer cargo syn 2.0.119 data/Field#ident..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 140 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident) => (ident.clonerust-analyzer cargo proc-macro2 1.0.107 impl#[Ident][Clone]clone().(), false), |
| 141 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (format_identrust-analyzer cargo quote 1.0.47 format/format_ident!!("_{}", index), true), |
| 142 | }; |
| 143 | |
| 144 | variants.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((&variant.identrust-analyzer cargo syn 2.0.119 data/Variant#ident., is_tuple, index, field_name, &field.tyrust-analyzer cargo syn 2.0.119 data/Field#ty., method)); |
| 145 | } |
| 146 | |
| 147 | if variants.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 148 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::panicrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/::no_into_fieldrust-analyzer cargo educe 0.6.0 trait_handlers/into/panic/no_into_field().(&target_ty)); |
| 149 | } |
| 150 | |
| 151 | for (variant_ident, is_tuple, index, field_name, ty, method) in variants { |
| 152 | let mut pattern_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 153 | let mut body_token_stream = proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().(); |
| 154 | |
| 155 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(method) = method { |
| 156 | body_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( #method(#field_name) )); |
| 157 | } else { |
| 158 | let field_ty = superrust-analyzer cargo educe 0.6.0 trait_handlers/into/::commonrust-analyzer cargo educe 0.6.0 trait_handlers/into/common/::to_hash_typerust-analyzer cargo educe 0.6.0 trait_handlers/into/common/to_hash_type().(ty); |
| 159 | |
| 160 | if target_ty.eqrust-analyzer cargo educe 0.6.0 common/tools/hash_type/impl#[HashType][`PartialEq<Self>`]eq().(&field_ty) { |
| 161 | body_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( #field_name )); |
| 162 | } else { |
| 163 | into_types.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ty); |
| 164 | |
| 165 | body_token_stream |
| 166 | .extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( ::core::convert::Into::into(#field_name) )); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | if is_tuple { |
| 171 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#index { |
| 172 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!(_,)); |
| 173 | } |
| 174 | |
| 175 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( #field_name, .. )); |
| 176 | |
| 177 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().( |
| 178 | quoterust-analyzer cargo quote 1.0.47 quote!!( Self::#variant_ident ( #pattern_token_stream ) => #body_token_stream, ), |
| 179 | ); |
| 180 | } else { |
| 181 | pattern_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!!( #field_name, .. )); |
| 182 | |
| 183 | arms_token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().( |
| 184 | quoterust-analyzer cargo quote 1.0.47 quote!!( Self::#variant_ident { #pattern_token_stream } => #body_token_stream, ), |
| 185 | ); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | let ident = &ast.identrust-analyzer cargo syn 2.0.119 derive/DeriveInput#ident.; |
| 190 | |
| 191 | let bound = bound.into_where_predicates_by_generic_parameters_check_typesrust-analyzer cargo educe 0.6.0 common/bound/impl#[Bound]into_where_predicates_by_generic_parameters_check_types().( |
| 192 | &ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..paramsrust-analyzer cargo syn 2.0.119 generics/Generics#params., |
| 193 | &synrust-analyzer cargo syn 2.0.119 crate/::parse2rust-analyzer cargo syn 2.0.119 parse2().(quoterust-analyzer cargo quote 1.0.47 quote!!(::core::convert::Into<#target_ty>)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 194 | &into_types, |
| 195 | &[], |
| 196 | ); |
| 197 | |
| 198 | // clone generics in order to not to affect other Into<T> implementations |
| 199 | let mut generics = ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..clonerust-analyzer cargo syn 2.0.119 gen/clone/impl#[`crate::Generics`][Clone]clone().(); |
| 200 | |
| 201 | let where_clause = generics.make_where_clauserust-analyzer cargo syn 2.0.119 generics/impl#[Generics]make_where_clause().(); |
| 202 | |
| 203 | for where_predicate in bound { |
| 204 | where_clause.predicatesrust-analyzer cargo syn 2.0.119 generics/WhereClause#predicates..pushrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]push().(where_predicate); |
| 205 | } |
| 206 | |
| 207 | let (impl_generics, ty_generics, _) = ast.genericsrust-analyzer cargo syn 2.0.119 derive/DeriveInput#generics..split_for_implrust-analyzer cargo syn 2.0.119 generics/impl#[Generics]split_for_impl().(); |
| 208 | |
| 209 | token_stream.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! { |
| 210 | impl #impl_generics ::core::convert::Into<#target_ty> for #ident #ty_generics #where_clause { |
| 211 | #[inline] |
| 212 | fn into(self) -> #target_ty { |
| 213 | match self { |
| 214 | #arms_token_stream |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | }); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 223 | } |
| 224 | } |