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.

Revisions

  1. George Takumi Crary revised this gist Jan 6, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original 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>> = &mut w;
    let world : &Vec<Vec<Wall>> = &w;
    println!("{}", pitch);
    for y in 0..600 {
    for x in 0..800 {
  2. George Takumi Crary revised this gist Jan 6, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original 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() {
    }
    ...
    }
    }
    }
  3. George Takumi Crary created this gist Jan 6, 2018.
    37 changes: 37 additions & 0 deletions gistfile1.txt
    Original 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