Yes thanks, It works but I have now a new error in my code:
That's my code :
fn main() {
let mut img = image::open("C:/Users/hp/Desktop/Multiprocessor real-time scheduling/Project2/data/aLIEz.jpg").unwrap();
struct Rectangles {
line1: Vec<(u32, u32, u32, u32)>,
line2: Vec<(u32, u32, u32, u32)>,
line3: Vec<(u32, u32, u32, u32)>,
}
let rectangles1 = Rectangles {
line1: vec![(250, 325, 350, 415)],
line2: vec![(225, 500, 350, 615)],
line3: vec![(50, 825, 185, 980)],
};
let img_parts: Vec<_> = rectangles1.line1.iter()
.map(|(start_i, start_j, stop_i, stop_j)| img.sub_image(*start_i, *start_j, stop_i-start_i, stop_j-start_j)).collect();
img.save("C:/Users/hp/Desktop/Multiprocessor real-time scheduling/Project2/data_output/test12.png").unwrap();
}
Please find the new error below :
error: captured variable cannot escape FnMut
closure body
--> src\main.rs:45:47
|
16 | let mut img = image::open("C:/Users/hp/Desktop/Multiprocessor real-time scheduling/Project2/data/aLIEz.jpg").unwrap();
| ------- variable defined here
...
45 | .map(|(start_i, start_j, stop_i, stop_j)| img.sub_image(*start_i, *start_j, stop_i-start_i, stop_j-start_j)).collect();
| - ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | returns a reference to a captured variable which escapes the closure body
| | variable captured here
| inferred to be a FnMut
closure
|
= note: FnMut
closures only have access to their captured variables while they are executing...
= note: ...therefore, they cannot allow references to captured variables to escape