The error is saying what you are returning is not DynamicImage but something else. What you are returning is the tuple return (image, image_format); So you need to change the return type or change what you are returning.
You have learnt about the empty tuple type (). Now, you will use a tuple to return multiple values. Unlike other types, a tuple can contain more than one type.
// The Vec type can only contain one type.
let my_vec = vec![1u8, 2u16, 3u32];
// Tuples can contain multiple types.
let my_tuple = (1u8, 2u16, 3u32);
Task: From find_image_from_path, return a tuple containing the DynamicImage and ImageFormat of the image, in that order.
Run cargo test --bin combiner to see if you correctly completed the task.
When you are done, type the following for the next lesson:
$ fcc 33
fn find_image_from_path(path: String) -> (DynamicImage, ImageFormat) {
let image_reader = Reader::open(path).unwrap();
let image_format = image_reader.format().unwrap();
let image = image_reader.decode().unwrap();
return (image, image_format);
}
passes the tests but panics later so its progress Thanks David
Im slowly working my way through all his videos and beginning to understand more and more. Still finding a few things that go wrong when trying to follow along, I suspect my extensions in VSCode are being very strict.
Let me know if you have tried to follow along and what issues you hit.
Heres me scratching my head worrying about a comma while doing a tutorial on Structs
Wow, that’s amazing, I missed that when I landed on the page before. People recommended it as a great Rust book, but I saw the prices for the physical edition and was deterred. Is there any guarantee though that she keeps that digital version up for free?