Debian Codegraph @

src/trait_handlers/clone/models/field_attribute.rs

raw symbols SCIP
1 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#, Attributerust-analyzer cargo syn 2.0.119 attr/Attribute#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Pathrust-analyzer cargo syn 2.0.119 path/Path#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!};
2
3 use craterust-analyzer cargo educe 0.6.0 crate/::{commonrust-analyzer cargo educe 0.6.0 common/::pathrust-analyzer cargo educe 0.6.0 common/path/::meta_2_pathrust-analyzer cargo educe 0.6.0 common/path/meta_2_path()., panicrust-analyzer cargo educe 0.6.0 panic/, supported_traitsrust-analyzer cargo educe 0.6.0 supported_traits/::Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#};
4
5 pub(craterust-analyzer cargo educe 0.6.0 crate/) struct FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttribute# {
6 pub(craterust-analyzer cargo educe 0.6.0 crate/) methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttribute#method.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Pathrust-analyzer cargo syn 2.0.119 path/Path#>,
7 }
8
9 pub(craterust-analyzer cargo educe 0.6.0 crate/) struct FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder# {
10 pub(craterust-analyzer cargo educe 0.6.0 crate/) enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder#enable_method.: bool,
11 }
12
13 impl FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder# {
14 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn build_from_clone_metarust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/impl#[FieldAttributeBuilder]build_from_clone_meta().(&self, 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#<FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttribute#> {
15 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().("Clone"));
16
17 let mut method = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
18
19 let correct_usage_for_clone_attribute = {
20 let mut usage = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
21
22 if self.enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder#enable_method. {
23 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(Clone(method(path_to_method)))]));
24 }
25
26 usage
27 };
28
29 match meta {
30 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Pathrust-analyzer cargo syn 2.0.119 attr/Meta#Path#(_) | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.119 attr/Meta#NameValue#(_) => {
31 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().(
32 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().(),
33 &correct_usage_for_clone_attribute,
34 ));
35 },
36 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(list) => {
37 let result =
38 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().;
39
40 let mut method_is_set = false;
41
42 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> {
43 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().() {
44 if ident rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."method" {
45 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.enable_methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttributeBuilder#enable_method. {
46 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false);
47 }
48
49 let v = meta_2_pathrust-analyzer cargo educe 0.6.0 common/path/meta_2_path().(&meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
50
51 if method_is_set {
52 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));
53 }
54
55 method_is_set = true;
56
57 method = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v);
58
59 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
60 }
61 }
62
63 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false)
64 };
65
66 for p in result {
67 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(). {
68 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().(
69 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().(),
70 &correct_usage_for_clone_attribute,
71 ));
72 }
73 }
74 },
75 }
76
77 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttribute# {
78 methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttribute#method.,
79 })
80 }
81
82 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().(
83 &self,
84 attributes: &[Attributerust-analyzer cargo syn 2.0.119 attr/Attribute#],
85 traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#],
86 ) -> 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/clone/models/field_attribute/FieldAttribute#> {
87 let mut output = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
88
89 for attribute in attributes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
90 let path = attribute.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Attribute]path().();
91
92 if path.is_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]is_ident().("educe") {
93 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. {
94 let result =
95 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().;
96
97 for meta in result {
98 let path = meta.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().();
99
100 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) {
101 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t) => t,
102 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().())),
103 };
104
105 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) {
106 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().()));
107 }
108
109 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#::Clonerust-analyzer cargo educe 0.6.0 supported_traits/Trait#Clone# {
110 if output.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
111 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().()));
112 }
113
114 output = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.build_from_clone_metarust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/impl#[FieldAttributeBuilder]build_from_clone_meta().(&meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
115 }
116 }
117 }
118 }
119 }
120
121 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/clone/models/field_attribute/FieldAttribute# {
122 methodrust-analyzer cargo educe 0.6.0 trait_handlers/clone/models/field_attribute/FieldAttribute#method.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
123 }))
124 }
125 }