MCPcopy Create free account
hub / github.com/biblius/validify / map_from_fields

Function map_from_fields

validify_derive/src/payload.rs:211–241  ·  view source on GitHub ↗
(info: &FieldInfo)

Source from the content-addressed store, hash-verified

209}
210
211fn map_from_fields(info: &FieldInfo) -> proc_macro2::TokenStream {
212 let ident = info.field.ident.as_ref().unwrap();
213
214 if info.is_option() {
215 if info.is_nested_validify() && info.is_list() {
216 return quote!(
217 #ident: payload.#ident.map(|v|v.into_iter().map(|el|el.into()).collect()),
218 );
219 }
220
221 if info.is_nested_validify() {
222 return quote!(
223 #ident: payload.#ident.map(|o|o.into()),
224 );
225 }
226
227 quote!(
228 #ident: payload.#ident,
229 )
230 } else {
231 if info.is_nested_validify() && info.is_list() {
232 return quote!(#ident: payload.#ident.unwrap().into_iter().map(|el|el.into()).collect(),);
233 }
234
235 if info.is_nested_validify() {
236 return quote!(#ident: payload.#ident.unwrap().into(),);
237 }
238
239 quote!(#ident: payload.#ident.unwrap(),)
240 }
241}
242
243fn map_into_fields(info: &FieldInfo) -> proc_macro2::TokenStream {
244 let ident = info.field.ident.as_ref().unwrap();

Callers

nothing calls this directly

Calls 3

is_optionMethod · 0.80
is_nested_validifyMethod · 0.80
is_listMethod · 0.80

Tested by

no test coverage detected