Last active
January 6, 2018 04:28
-
-
Save gmtcrary/261eef5ac9f63d0f6b36dde3f08595e8 to your computer and use it in GitHub Desktop.
Revisions
-
George Takumi Crary revised this gist
Jan 6, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ pub struct Wall{ } 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 { -
George Takumi Crary revised this gist
Jan 6, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ pub fn main() { canvas.present(); for event in event_pump.poll_iter() { ... } } } -
George Takumi Crary created this gist
Jan 6, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ #[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>> = &mut 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