Compilation of this repo on rustc 1.80.0 used to fail with:
error[E0499]: cannot borrow `target` as mutable more than once at a time
--> src/map.rs:300:25
|
295 | let mut piet_context = target.render_context();
| ----------------------- first mutable borrow occurs here
...
300 | let image_buf = target.to_image_buf(ImageFormat::RgbaPremul).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
...
311 | }
| - first borrow might be used here, when `piet_context` is dropped and runs the `Drop` code for type `CoreGraphicsContext`
error[E0499]: cannot borrow `target` as mutable more than once at a time
--> src/map.rs:1367:41
|
1312 | let mut piet_context = target.render_context();
| ----------------------- first mutable borrow occurs here
...
1367 | let image_buf = target.to_image_buf(ImageFormat::RgbaPremul).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
...
1370 | });
| - first borrow might be used here, when `piet_context` is dropped and runs the `Drop` code for type `CoreGraphicsContext`
error[E0499]: cannot borrow `target` as mutable more than once at a time
--> src/map.rs:1400:41
|
1379 | let mut piet_context = target.render_context();
| ----------------------- first mutable borrow occurs here
...
1400 | let image_buf = target.to_image_buf(ImageFormat::RgbaPremul).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
...
1403 | });
| - first borrow might be used here, when `piet_context` is dropped and runs the `Drop` code for type `CoreGraphicsContext`
This PR includes changes to ensure the mutable borrows are complete before subsequent calls in order to run without issues on modern Rust versions.
This looks great to me, thanks @BodoMinea. I'm not a Rust programmer so unable to comment on the code, cc @dabreegster and @maxwell8888 in case you don't get notified.
Compilation of this repo on rustc 1.80.0 used to fail with:
This PR includes changes to ensure the mutable borrows are complete before subsequent calls in order to run without issues on modern Rust versions.