| 1 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::Spanrust-analyzer cargo proc-macro2 1.0.107 Span#; |
| 2 | use synrust-analyzer cargo syn 2.0.119 crate/::{punctuatedrust-analyzer cargo syn 2.0.119 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#, spannedrust-analyzer cargo syn 2.0.119 spanned/::Spannedrust-analyzer cargo syn 2.0.119 spanned/Spanned#, Attributerust-analyzer cargo syn 2.0.119 attr/Attribute#, Exprrust-analyzer cargo syn 2.0.119 expr/Expr#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!, Typerust-analyzer cargo syn 2.0.119 ty/Type#}; |
| 3 | |
| 4 | use craterust-analyzer cargo educe 0.6.0 crate/::{ |
| 5 | commonrust-analyzer cargo educe 0.6.0 common/::exprrust-analyzer cargo educe 0.6.0 common/expr/::{auto_adjust_exprrust-analyzer cargo educe 0.6.0 common/expr/auto_adjust_expr()., meta_2_exprrust-analyzer cargo educe 0.6.0 common/expr/meta_2_expr().}, |
| 6 | panicrust-analyzer cargo educe 0.6.0 panic/, |
| 7 | supported_traitsrust-analyzer cargo educe 0.6.0 supported_traits/::Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#, |
| 8 | }; |
| 9 | |
| 10 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute# { |
| 11 | pub(craterust-analyzer cargo educe 0.6.0 crate/) flagrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#flag.: bool, |
| 12 | pub(craterust-analyzer cargo educe 0.6.0 crate/) expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#expression.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Exprrust-analyzer cargo syn 2.0.119 expr/Expr#>, |
| 13 | pub(craterust-analyzer cargo educe 0.6.0 crate/) spanrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, |
| 14 | } |
| 15 | |
| 16 | pub(craterust-analyzer cargo educe 0.6.0 crate/) struct FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder# { |
| 17 | pub(craterust-analyzer cargo educe 0.6.0 crate/) enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_flag.: bool, |
| 18 | pub(craterust-analyzer cargo educe 0.6.0 crate/) enable_expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_expression.: bool, |
| 19 | } |
| 20 | |
| 21 | impl FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder# { |
| 22 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn build_from_default_metarust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/impl#[FieldAttributeBuilder]build_from_default_meta().( |
| 23 | &self, |
| 24 | meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#, |
| 25 | ty: &Typerust-analyzer cargo syn 2.0.119 ty/Type#, |
| 26 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#> { |
| 27 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(meta.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().().is_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]is_ident().("Default")); |
| 28 | |
| 29 | let mut flag = false; |
| 30 | let mut expression = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 31 | |
| 32 | let correct_usage_for_default_attribute = { |
| 33 | let mut usage = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 34 | |
| 35 | if self.enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_flag. { |
| 36 | usage.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(stringifyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/stringify!!(#[educe(Default)])); |
| 37 | } |
| 38 | |
| 39 | if self.enable_expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_expression. { |
| 40 | usage.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(stringifyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/stringify!!(#[educe(Default = expr)])); |
| 41 | |
| 42 | usage.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(stringifyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/stringify!!(#[educe(Default(expression = expr))])); |
| 43 | } |
| 44 | |
| 45 | usage |
| 46 | }; |
| 47 | |
| 48 | match meta { |
| 49 | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Pathrust-analyzer cargo syn 2.0.119 attr/Meta#Path#(_) => { |
| 50 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_flag. { |
| 51 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::attribute_incorrect_formatrust-analyzer cargo educe 0.6.0 panic/attribute_incorrect_format().( |
| 52 | meta.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().(), |
| 53 | &correct_usage_for_default_attribute, |
| 54 | )); |
| 55 | } |
| 56 | |
| 57 | flag = true; |
| 58 | }, |
| 59 | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.119 attr/Meta#NameValue#(name_value) => { |
| 60 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.enable_expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_expression. { |
| 61 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::attribute_incorrect_formatrust-analyzer cargo educe 0.6.0 panic/attribute_incorrect_format().( |
| 62 | meta.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().(), |
| 63 | &correct_usage_for_default_attribute, |
| 64 | )); |
| 65 | } |
| 66 | |
| 67 | expression = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(auto_adjust_exprrust-analyzer cargo educe 0.6.0 common/expr/auto_adjust_expr().(name_value.valuerust-analyzer cargo syn 2.0.119 attr/MetaNameValue#value..clonerust-analyzer cargo syn 2.0.119 gen/clone/impl#[`crate::Expr`][Clone]clone().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ty))); |
| 68 | }, |
| 69 | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(list) => { |
| 70 | let result = |
| 71 | list.parse_args_withrust-analyzer cargo syn 2.0.119 attr/impl#[MetaList]parse_args_with().(Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#::<Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!![,]>::parse_terminatedrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 72 | |
| 73 | let mut expression_is_set = false; |
| 74 | |
| 75 | let mut handler = |meta: Metarust-analyzer cargo syn 2.0.119 attr/Meta#| -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<bool> { |
| 76 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident) = meta.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().().get_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]get_ident().() { |
| 77 | match ident.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 78 | "expression" | "expr" => { |
| 79 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.enable_expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttributeBuilder#enable_expression. { |
| 80 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false); |
| 81 | } |
| 82 | |
| 83 | let v = meta_2_exprrust-analyzer cargo educe 0.6.0 common/expr/meta_2_expr().(&meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 84 | |
| 85 | if expression_is_set { |
| 86 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::parameter_resetrust-analyzer cargo educe 0.6.0 panic/parameter_reset().(ident)); |
| 87 | } |
| 88 | |
| 89 | expression_is_set = true; |
| 90 | |
| 91 | expression = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(auto_adjust_exprrust-analyzer cargo educe 0.6.0 common/expr/auto_adjust_expr().(v, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ty))); |
| 92 | |
| 93 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true); |
| 94 | }, |
| 95 | _ => (), |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false) |
| 100 | }; |
| 101 | |
| 102 | for p in result { |
| 103 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().handler(p)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 104 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::attribute_incorrect_formatrust-analyzer cargo educe 0.6.0 panic/attribute_incorrect_format().( |
| 105 | meta.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().(), |
| 106 | &correct_usage_for_default_attribute, |
| 107 | )); |
| 108 | } |
| 109 | } |
| 110 | }, |
| 111 | } |
| 112 | |
| 113 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute# { |
| 114 | flagrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#flag., |
| 115 | expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#expression., |
| 116 | spanrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#span.: meta.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(), |
| 117 | }) |
| 118 | } |
| 119 | |
| 120 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().( |
| 121 | &self, |
| 122 | attributes: &[Attributerust-analyzer cargo syn 2.0.119 attr/Attribute#], |
| 123 | traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#], |
| 124 | ty: &Typerust-analyzer cargo syn 2.0.119 ty/Type#, |
| 125 | ) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#> { |
| 126 | let mut output = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 127 | |
| 128 | for attribute in attributes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 129 | let path = attribute.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Attribute]path().(); |
| 130 | |
| 131 | if path.is_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]is_ident().("educe") { |
| 132 | if let Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(list) = &attribute.metarust-analyzer cargo syn 2.0.119 attr/Attribute#meta. { |
| 133 | let result = |
| 134 | list.parse_args_withrust-analyzer cargo syn 2.0.119 attr/impl#[MetaList]parse_args_with().(Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#::<Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!![,]>::parse_terminatedrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 135 | |
| 136 | for meta in result { |
| 137 | let path = meta.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().(); |
| 138 | |
| 139 | let t = match Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#::from_pathrust-analyzer cargo educe 0.6.0 supported_traits/impl#[Trait]from_path().(path) { |
| 140 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t) => t, |
| 141 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::unsupported_traitrust-analyzer cargo educe 0.6.0 panic/unsupported_trait().(meta.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().())), |
| 142 | }; |
| 143 | |
| 144 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().traits.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&t) { |
| 145 | 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_usedrust-analyzer cargo educe 0.6.0 panic/trait_not_used().(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().())); |
| 146 | } |
| 147 | |
| 148 | if t rust-analyzer cargo educe 0.6.0 supported_traits/impl#[Trait][`PartialEq<Self>`]eq().==rust-analyzer cargo educe 0.6.0 supported_traits/impl#[Trait][`PartialEq<Self>`]eq(). rust-analyzer cargo educe 0.6.0 supported_traits/impl#[Trait][`PartialEq<Self>`]eq().Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#::Defaultrust-analyzer cargo educe 0.6.0 supported_traits/Trait#Default# { |
| 149 | if output.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 150 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(panicrust-analyzer cargo educe 0.6.0 panic/::reuse_a_traitrust-analyzer cargo educe 0.6.0 panic/reuse_a_trait().(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().())); |
| 151 | } |
| 152 | |
| 153 | output = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.build_from_default_metarust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/impl#[FieldAttributeBuilder]build_from_default_meta().(&meta, ty)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(output.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute# { |
| 161 | flagrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#flag.: false, |
| 162 | expressionrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#expression.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 163 | spanrust-analyzer cargo educe 0.6.0 trait_handlers/default/models/field_attribute/FieldAttribute#span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().(), |
| 164 | })) |
| 165 | } |
| 166 | } |