Function binrw::until_exclusive

source ·
pub fn until_exclusive<Reader, T, CondFn, Arg, Ret>(
    cond: CondFn
) -> impl Fn(&mut Reader, Endian, Arg) -> BinResult<Ret>where
    T: for<'a> BinRead<Args<'a> = Arg>,
    Reader: Read + Seek,
    CondFn: Fn(&T) -> bool,
    Arg: Clone,
    Ret: FromIterator<T>,
Expand description

Creates a parser that reads items into a collection until a condition is met. The terminal item is discarded.

This helper can be used to read into any collection type that implements FromIterator.

Examples

#[derive(BinRead)]
struct NullTerminated {
    #[br(parse_with = until_exclusive(|&byte| byte == 0))]
    data: Vec<u8>,
}