Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Update texture in Rust  (Read 1388 times)

0 Members and 1 Guest are viewing this topic.

weremsoft

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Update texture in Rust
« on: December 13, 2018, 08:35:03 pm »
Anyone knows how to update the texture in rust? I have the following:


Quote
let mut image = Image::from_color(WIDTH, HEIGHT, &Color::GREEN).unwrap();
let mut texture = Texture::from_image(&image).unwrap();
let sprite = Sprite::with_texture(&texture); // -------- immutable borrow occurs here
texture.update_from_image(&image, 0, 0); // ERROR!!! --- cannot borrow `texture` as mutable because it is also borrowed as immutable


Thanks

 

anything