You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::io::Write;
fn encode() -> Vec<u8> {
let mut pngbuf: Vec<u8> = Vec::new();
{
let mut encoder = png::Encoder::new(std::io::Cursor::new(&mut pngbuf), 1, 1);
encoder.set_color(png::ColorType::Grayscale);
encoder.set_depth(png::BitDepth::Eight);
let mut writer = encoder
.write_header()
.unwrap()
.into_stream_writer()
.unwrap();
writer.write_all(b"x").unwrap();
}
pngbuf
}
leads to the following error:
error[E0597]: `pngbuf` does not live long enough
--> src/main.rs:7:66
|
7 | let mut encoder = png::Encoder::new(std::io::Cursor::new(&mut pngbuf), 1, 1);
| ---------------------^^^^^^^^^^^-
| | |
| | borrowed value does not live long enough
| argument requires that `pngbuf` is borrowed for `'static`
...
21 | }
| - `pngbuf` dropped here while still borrowed
error[E0505]: cannot move out of `pngbuf` because it is borrowed
--> src/main.rs:20:5
|
7 | let mut encoder = png::Encoder::new(std::io::Cursor::new(&mut pngbuf), 1, 1);
| ---------------------------------
| | |
| | borrow of `pngbuf` occurs here
| argument requires that `pngbuf` is borrowed for `'static`
...
20 | pngbuf
| ^^^^^^ move out of `pngbuf` occurs here
The issue and the possible solutions were previously discussed in #298 (comment)
Since #298 is closed and this is a actually different issue introduced only in v0.17 I'm submitting a new one.
The text was updated successfully, but these errors were encountered:
Sample code exhibiting the issue:
leads to the following error:
The issue and the possible solutions were previously discussed in #298 (comment)
Since #298 is closed and this is a actually different issue introduced only in v0.17 I'm submitting a new one.
The text was updated successfully, but these errors were encountered: