Debian Codegraph @

src/composites.rs

raw symbols SCIP
1 use proc_macro2rust-analyzer cargo proc-macro2 1.0.106 crate/::Spanrust-analyzer cargo proc-macro2 1.0.106 Span#;
2 use synrust-analyzer cargo syn 2.0.117 crate/::{
3 Errorrust-analyzer cargo syn 2.0.117 error/Error#, GenericParamrust-analyzer cargo syn 2.0.117 generics/GenericParam#, Genericsrust-analyzer cargo syn 2.0.117 generics/Generics#, Identrust-analyzer cargo proc-macro2 1.0.106 Ident#, Pathrust-analyzer cargo syn 2.0.117 path/Path#, PathSegmentrust-analyzer cargo syn 2.0.117 path/PathSegment#, Typerust-analyzer cargo syn 2.0.117 ty/Type#, TypeParamBoundrust-analyzer cargo syn 2.0.117 generics/TypeParamBound#,
4 punctuatedrust-analyzer cargo syn 2.0.117 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#,
5 };
6
7 use craterust-analyzer cargo postgres-derive 0.4.9 crate/::{caserust-analyzer cargo postgres-derive 0.4.9 case/::RenameRulerust-analyzer cargo postgres-derive 0.4.9 case/RenameRule#, overridesrust-analyzer cargo postgres-derive 0.4.9 overrides/::Overridesrust-analyzer cargo postgres-derive 0.4.9 overrides/Overrides#};
8
9 pub struct Fieldrust-analyzer cargo postgres-derive 0.4.9 composites/Field# {
10 pub namerust-analyzer cargo postgres-derive 0.4.9 composites/Field#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
11 pub identrust-analyzer cargo postgres-derive 0.4.9 composites/Field#ident.: Identrust-analyzer cargo proc-macro2 1.0.106 Ident#,
12 pub type_rust-analyzer cargo postgres-derive 0.4.9 composites/Field#type_.: Typerust-analyzer cargo syn 2.0.117 ty/Type#,
13 }
14
15 impl Fieldrust-analyzer cargo postgres-derive 0.4.9 composites/Field# {
16 pub fn parserust-analyzer cargo postgres-derive 0.4.9 composites/impl#[Field]parse().(raw: &synrust-analyzer cargo syn 2.0.117 crate/::Fieldrust-analyzer cargo syn 2.0.117 data/Field#, rename_all: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<RenameRulerust-analyzer cargo postgres-derive 0.4.9 case/RenameRule#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Fieldrust-analyzer cargo postgres-derive 0.4.9 composites/Field#, Errorrust-analyzer cargo syn 2.0.117 error/Error#> {
17 let overrides = Overridesrust-analyzer cargo postgres-derive 0.4.9 overrides/Overrides#::extractrust-analyzer cargo postgres-derive 0.4.9 overrides/impl#[Overrides]extract().(&raw.attrsrust-analyzer cargo syn 2.0.117 data/Field#attrs., false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
18 let ident = raw.identrust-analyzer cargo syn 2.0.117 data/Field#ident..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][Clone]clone().();
19
20 // field level name override takes precendence over container level rename_all override
21 let name = match overrides.namerust-analyzer cargo postgres-derive 0.4.9 overrides/Overrides#name. {
22 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) => n,
23 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
24 let name = ident.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
25 let stripped = name.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("r#").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(name);
26
27 match rename_all {
28 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rule) => rule.apply_to_fieldrust-analyzer cargo postgres-derive 0.4.9 case/impl#[RenameRule]apply_to_field().(&stripped),
29 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => stripped,
30 }
31 }
32 };
33
34 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Fieldrust-analyzer cargo postgres-derive 0.4.9 composites/Field# {
35 namerust-analyzer cargo postgres-derive 0.4.9 composites/Field#name.,
36 identrust-analyzer cargo postgres-derive 0.4.9 composites/Field#ident.,
37 type_rust-analyzer cargo postgres-derive 0.4.9 composites/Field#type_.: raw.tyrust-analyzer cargo syn 2.0.117 data/Field#ty..clonerust-analyzer cargo syn 2.0.117 gen/clone/impl#[`crate::Type`][Clone]clone().(),
38 })
39 }
40 }
41
42 pub(craterust-analyzer cargo postgres-derive 0.4.9 crate/) fn append_generic_boundrust-analyzer cargo postgres-derive 0.4.9 composites/append_generic_bound().(mut generics: Genericsrust-analyzer cargo syn 2.0.117 generics/Generics#, bound: &TypeParamBoundrust-analyzer cargo syn 2.0.117 generics/TypeParamBound#) -> Genericsrust-analyzer cargo syn 2.0.117 generics/Generics# {
43 for param in &mut generics.paramsrust-analyzer cargo syn 2.0.117 generics/Generics#params. {
44 if let GenericParamrust-analyzer cargo syn 2.0.117 generics/GenericParam#::Typerust-analyzer cargo syn 2.0.117 generics/GenericParam#Type#(param) = param {
45 param.boundsrust-analyzer cargo syn 2.0.117 generics/TypeParam#bounds..pushrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]push().(bound.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().())
46 }
47 }
48 generics
49 }
50
51 pub(craterust-analyzer cargo postgres-derive 0.4.9 crate/) fn new_derive_pathrust-analyzer cargo postgres-derive 0.4.9 composites/new_derive_path().(last: PathSegmentrust-analyzer cargo syn 2.0.117 path/PathSegment#) -> Pathrust-analyzer cargo syn 2.0.117 path/Path# {
52 let mut path = Pathrust-analyzer cargo syn 2.0.117 path/Path# {
53 leading_colonrust-analyzer cargo syn 2.0.117 path/Path#leading_colon.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
54 segmentsrust-analyzer cargo syn 2.0.117 path/Path#segments.: Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#::newrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]new().(),
55 };
56 path.segmentsrust-analyzer cargo syn 2.0.117 path/Path#segments.
57 .pushrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]push().(Identrust-analyzer cargo proc-macro2 1.0.106 Ident#::newrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]new().("postgres_types", Spanrust-analyzer cargo proc-macro2 1.0.106 Span#::call_siterust-analyzer cargo proc-macro2 1.0.106 impl#[Span]call_site().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
58 path.segmentsrust-analyzer cargo syn 2.0.117 path/Path#segments..pushrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]push().(last);
59 path
60 }