I'm fairly new to Rust and working on a little personal project. I'm using
reqwest and started learning about the
Result type. After trial and error, I managed to get a function working which has the following signature:
pub fn product_page(url: &str) -> Result<impl ProductPage, Box<dyn Error>>
I had to use
Box<dyn Error> because of
reqwest but I still wanted to be able to return my own type of Error. I solved this by returning
at the end of the function.
However, I'm not sure why I have to use
? in the end. Another solution that worked was
.into() which I also found confusing.
My question is: why do I need to use
.into(), how they work and is there a difference between them? As a secondary question: is there a better, more common way to return my own Error, compared to what I have done?