Skip to content

Instantly share code, notes, and snippets.

@gmtcrary
Last active January 6, 2018 04:28
Show Gist options
  • Select an option

  • Save gmtcrary/261eef5ac9f63d0f6b36dde3f08595e8 to your computer and use it in GitHub Desktop.

Select an option

Save gmtcrary/261eef5ac9f63d0f6b36dde3f08595e8 to your computer and use it in GitHub Desktop.
#[derive(Copy, Clone)]
pub struct Wall{
full : bool,
color : Color
}
pub fn main() {
let render_statics = |buffer: &mut [u8], pitch: usize| {
let world : &Vec<Vec<Wall>> = &w;
println!("{}", pitch);
for y in 0..600 {
for x in 0..800 {
let offset = y*pitch + x*3;
buffer[offset] = 255 as u8;
buffer[offset + 1] = 0 as u8;
buffer[offset + 2] = 0;
}
}
};
'running: loop {
texture.with_lock(None, render_statics).unwrap();
canvas.copy(&texture, None, None).unwrap();
canvas.present();
for event in event_pump.poll_iter() {
...
}
}
}
error[E0382]: use of moved value: `render_statics`
--> src\main.rs:166:33
|
166 | texture.with_lock(None, render_statics).unwrap();
| ^^^^^^^^^^^^^^ value moved here in previous iteration of loop
|
= note: move occurs because `render_statics` has type `[closure@src\main.rs:144:26: 155:6 w:&mut std::vec::Vec<std::vec::Vec<Wall>>]`, which does not implement the `Copy` trait
@gmtcrary
Copy link
Author

gmtcrary commented Jan 6, 2018

screenshot 2018-01-05 20 20 47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment