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

Missing docs/examples for decoder.next_image() #34

Closed
Shnatsel opened this issue Feb 28, 2019 · 0 comments · Fixed by #37
Closed

Missing docs/examples for decoder.next_image() #34

Shnatsel opened this issue Feb 28, 2019 · 0 comments · Fixed by #37

Comments

@Shnatsel
Copy link

The function decoder.next_image() is under-documented.

First off, it is not clear how this function relates to read_image() and what the difference between them is.

Second, the naive approach to using it does not compile:

fn decode(data: &[u8]) {
    let cursor = Cursor::new(data);
    if let Ok(mut decoder) = Decoder::new(cursor) {
        while decoder.more_images() {
            decoder.next_image();
        }
    }
}

This fails with the following error:

error[E0382]: borrow of moved value: `decoder`
  --> src/bin/tiff-afl-multi.rs:11:19
   |
11 |             while decoder.more_images() {
   |                   ^^^^^^^ value borrowed here after move
12 |                 decoder.next_image();
   |                 ------- value moved here, in previous iteration of loop
   |
   = note: move occurs because `decoder` has type `tiff::decoder::Decoder<std::io::Cursor<&[u8]>>`, which does not implement the `Copy` trait

A code example that uses it correctly would be appreciated.

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

Successfully merging a pull request may close this issue.

1 participant