Debian Codegraph @

src/trait_handlers/deref_mut/models/field_attribute.rs

raw symbols SCIP
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#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Tokenrust-analyzer cargo syn 2.0.119 token/Token!};
3
4 use craterust-analyzer cargo educe 0.6.0 crate/::{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#};
5
6 pub(craterust-analyzer cargo educe 0.6.0 crate/) struct FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute# {
7 pub(craterust-analyzer cargo educe 0.6.0 crate/) flagrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute#flag.: bool,
8 pub(craterust-analyzer cargo educe 0.6.0 crate/) spanrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute#span.: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#,
9 }
10
11 pub(craterust-analyzer cargo educe 0.6.0 crate/) struct FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttributeBuilder# {
12 pub(craterust-analyzer cargo educe 0.6.0 crate/) enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttributeBuilder#enable_flag.: bool,
13 }
14
15 impl FieldAttributeBuilderrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttributeBuilder# {
16 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn build_from_deref_mut_metarust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/impl#[FieldAttributeBuilder]build_from_deref_mut_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/deref_mut/models/field_attribute/FieldAttribute#> {
17 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().("DerefMut"));
18
19 let correct_usage_for_deref_mut_attribute = {
20 let mut usage = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
21
22 if self.enable_flagrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttributeBuilder#enable_flag. {
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(DerefMut)]));
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#(_) => {
31 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/deref_mut/models/field_attribute/FieldAttributeBuilder#enable_flag. {
32 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().(
33 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().(),
34 &correct_usage_for_deref_mut_attribute,
35 ));
36 }
37 },
38 Metarust-analyzer cargo syn 2.0.119 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.119 attr/Meta#NameValue#(_) | Metarust-analyzer cargo syn 2.0.119 attr/Meta#::Listrust-analyzer cargo syn 2.0.119 attr/Meta#List#(_) => {
39 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().(
40 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().(),
41 &correct_usage_for_deref_mut_attribute,
42 ));
43 },
44 }
45
46 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAttributerust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute# {
47 flagrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute#flag.: true, spanrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute#span.: meta.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().()
48 })
49 }
50
51 pub(craterust-analyzer cargo educe 0.6.0 crate/) fn build_from_attributesrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/impl#[FieldAttributeBuilder]build_from_attributes().(
52 &self,
53 attributes: &[Attributerust-analyzer cargo syn 2.0.119 attr/Attribute#],
54 traits: &[Traitrust-analyzer cargo educe 0.6.0 supported_traits/Trait#],
55 ) -> 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/deref_mut/models/field_attribute/FieldAttribute#> {
56 let mut output = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
57
58 for attribute in attributes.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
59 let path = attribute.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Attribute]path().();
60
61 if path.is_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]is_ident().("educe") {
62 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. {
63 let result =
64 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().;
65
66 for meta in result {
67 let path = meta.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Meta]path().();
68
69 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) {
70 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t) => t,
71 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().())),
72 };
73
74 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) {
75 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().()));
76 }
77
78 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#::DerefMutrust-analyzer cargo educe 0.6.0 supported_traits/Trait#DerefMut# {
79 if output.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
80 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().()));
81 }
82
83 output = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.build_from_deref_mut_metarust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/impl#[FieldAttributeBuilder]build_from_deref_mut_meta().(&meta)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
84 }
85 }
86 }
87 }
88 }
89
90 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/deref_mut/models/field_attribute/FieldAttribute# {
91 flagrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/models/field_attribute/FieldAttribute#flag.: false, spanrust-analyzer cargo educe 0.6.0 trait_handlers/deref_mut/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().()
92 }))
93 }
94 }