ion_proc/value/mod.rs
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6
7use convert_case::{Case, Casing as _};
8pub(crate) use from::*;
9use proc_macro2::Ident;
10use quote::format_ident;
11use syn::Field;
12pub(crate) use to::*;
13
14pub(crate) mod from;
15pub(crate) mod to;
16
17fn field_to_ident_key(field: &Field, index: usize) -> (Ident, String) {
18 if let Some(ident) = &field.ident {
19 (ident.clone(), ident.to_string().to_case(Case::Camel))
20 } else {
21 let ident = format_ident!("_self_{}", index);
22 (ident, index.to_string())
23 }
24}