| 1 | use synrust-analyzer cargo syn 2.0.117 crate/::{Errorrust-analyzer cargo syn 2.0.117 error/Error#, Fieldsrust-analyzer cargo syn 2.0.117 data/Fields#, Identrust-analyzer cargo proc-macro2 1.0.106 Ident#}; |
| 2 | |
| 3 | 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#}; |
| 4 | |
| 5 | pub struct Variantrust-analyzer cargo postgres-derive 0.4.9 enums/Variant# { |
| 6 | pub identrust-analyzer cargo postgres-derive 0.4.9 enums/Variant#ident.: Identrust-analyzer cargo proc-macro2 1.0.106 Ident#, |
| 7 | pub namerust-analyzer cargo postgres-derive 0.4.9 enums/Variant#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 8 | } |
| 9 | |
| 10 | impl Variantrust-analyzer cargo postgres-derive 0.4.9 enums/Variant# { |
| 11 | pub fn parserust-analyzer cargo postgres-derive 0.4.9 enums/impl#[Variant]parse().(raw: &synrust-analyzer cargo syn 2.0.117 crate/::Variantrust-analyzer cargo syn 2.0.117 data/Variant#, 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#<Variantrust-analyzer cargo postgres-derive 0.4.9 enums/Variant#, Errorrust-analyzer cargo syn 2.0.117 error/Error#> { |
| 12 | match raw.fieldsrust-analyzer cargo syn 2.0.117 data/Variant#fields. { |
| 13 | Fieldsrust-analyzer cargo syn 2.0.117 data/Fields#::Unitrust-analyzer cargo syn 2.0.117 data/Fields#Unit# => {} |
| 14 | _ => { |
| 15 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.117 error/Error#::new_spannedrust-analyzer cargo syn 2.0.117 error/impl#[Error]new_spanned().( |
| 16 | raw, |
| 17 | "non-C-like enums are not supported", |
| 18 | )); |
| 19 | } |
| 20 | } |
| 21 | 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/Variant#attrs., false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 22 | |
| 23 | // variant level name override takes precendence over container level rename_all override |
| 24 | let name = overrides.namerust-analyzer cargo postgres-derive 0.4.9 overrides/Overrides#name..unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| match rename_all { |
| 25 | 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().(&raw.identrust-analyzer cargo syn 2.0.117 data/Variant#ident..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 26 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => raw.identrust-analyzer cargo syn 2.0.117 data/Variant#ident..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 27 | }); |
| 28 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Variantrust-analyzer cargo postgres-derive 0.4.9 enums/Variant# { |
| 29 | identrust-analyzer cargo postgres-derive 0.4.9 enums/Variant#ident.: raw.identrust-analyzer cargo syn 2.0.117 data/Variant#ident..clonerust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][Clone]clone().(), |
| 30 | namerust-analyzer cargo postgres-derive 0.4.9 enums/Variant#name., |
| 31 | }) |
| 32 | } |
| 33 | } |