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

Function map_into_fields

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

Source from the content-addressed store, hash-verified

241}
242
243fn map_into_fields(info: &FieldInfo) -> proc_macro2::TokenStream {
244 let ident = info.field.ident.as_ref().unwrap();
245
246 if info.is_option() {
247 if info.is_nested_validify() && info.is_list() {
248 return quote!(#ident: original.#ident.map(|v| v.into_iter().map(|el|el.into()).collect()),);
249 }
250
251 if info.is_nested_validify() {
252 return quote!(#ident: original.#ident.map(|o|o.into()),);
253 }
254
255 quote!(#ident: original.#ident,)
256 } else {
257 if info.is_nested_validify() && info.is_list() {
258 return quote!(#ident: Some(original.#ident.into_iter().map(|el|el.into()).collect()),);
259 }
260
261 if info.is_nested_validify() {
262 return quote!(#ident: Some(original.#ident.into()),);
263 }
264
265 quote!(#ident: Some(original.#ident),)
266 }
267}
268
269fn payload_path_angle_bracketed(path: &mut syn::TypePath) {
270 // Type is contained in a List<T>. It will always have angle args and will

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