Last active
January 6, 2018 04:28
-
-
Save gmtcrary/261eef5ac9f63d0f6b36dde3f08595e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[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 |
Author
gmtcrary
commented
Jan 6, 2018

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