pub fn args_iter<R, T, Arg, Ret, It>(
it: It,
) -> impl FnOnce(&mut R, Endian, ()) -> BinResult<Ret>where
T: for<'a> BinRead<Args<'a> = Arg>,
R: Read + Seek,
Arg: Clone,
Ret: FromIterator<T>,
It: IntoIterator<Item = Arg>,Expand description
Creates a parser that builds a collection using items from the given iterable object as arguments for the parser.
This helper can be used to read into any collection type that implements
FromIterator.
§Examples
Reading an object containing header data followed by body data:
#[derive(BinRead)]
#[br(big)]
struct Header {
count: u16,
#[br(args { count: count.into() })]
sizes: Vec<u16>,
}
#[derive(BinRead)]
#[br(big)]
struct Object {
header: Header,
#[br(parse_with = args_iter(header.sizes.iter().map(|&size| -> <Vec<u8> as BinRead>::Args<'_> {
args! { count: size.into() }
})))]
segments: Vec<Vec<u8>>,
}