Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map_stream, parse_with and args together fail to compile #240

Closed
himikof opened this issue Nov 26, 2023 · 1 comment
Closed

map_stream, parse_with and args together fail to compile #240

himikof opened this issue Nov 26, 2023 · 1 comment
Assignees

Comments

@himikof
Copy link

himikof commented Nov 26, 2023

Notice the following line in the example from #217:

    #[br(map_stream = |s| s.take_seek(16), parse_with = |r, e, _:()| until_eof(r, e, (v,)))]

I expect there to be a simpler way to achieve this:

    #[br(map_stream = |s| s.take_seek(16), parse_with = until_eof, args(v))]

Surprisingly, this fails to compile:

error[E0308]: mismatched types
   --> src/test.rs:46:9
    |
461 |     #[derive(Debug, BinRead)]
    |                     ------- this type parameter
...
467 |         #[br(map_stream = |s| s.take_seek(16), parse_with = helpers::until_eof, args(v))]
    |                                                             ------- arguments to this function are incorrect
468 |         data: Vec<Thing>,
    |         ^^^^ expected `&mut R`, found `&mut TakeSeek<&mut R>`
    |
    = note: expected mutable reference `&mut R`
               found mutable reference `&mut TakeSeek<&mut R>`
note: function defined here
   --> /home/nofitserov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/binrw-0.13.1/src/helpers.rs:213:8
    |
213 | pub fn until_eof<Reader, T, Arg, Ret>(
    |        ^^^^^^^^^

It seems that currently parse_function_args_type_hint unconditionally asserts/requires that the first argument to the parse function is of type &mut R, regardless of map_stream presence.

@csnover csnover self-assigned this Nov 28, 2023
csnover added a commit to csnover/binrw that referenced this issue Nov 28, 2023
@csnover
Copy link
Collaborator

csnover commented Nov 29, 2023

Thank you for your report! This issue is fixed in 0.13.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants