i think using generics would actually make this more simple fn validate formats t  u  f  ptr const t  num  usize  f  f libvdaresult vec u where f  fnmut  t libvdaresult u do validation convert unsafe slice  from raw parts ptr  size  iter  map f  collect libvdaresult vec and in the caller let input formats validate formats vda cap input formats  vda cap num input formats  inputformat  new  let output formats validate formats vda cap outut formats  vda cap num output formats  outputformat  new  