Open
Description
This isn't really a bug, but both my partner and I learning Rust felt that 5.14 was a beast! I had to cheat and look at the solution. My partner used an LLM and got an answer very much unlike what we had learned to date.
I was confused by something I saw in the solution brand. The example for how to use #from in 5.14 reads as follows:
#[derive(Error, Debug)]
pub enum MyError {
#[error("Failed to connect to the database")]
DatabaseError {
#[from]
inner: std::io::Error
}
}
Note that the syntax in the example uses the structure form of associating data with the enum
But in the solution, Database Error uses parens
[derive(Debug, thiserror::Error)]
pub enum TicketNewError {
...
#[error("{0}")]
InvalidStatus(#[from] ParseStatusError),
}
Tuples or tuple like syntax is covered in the Nullability lesson 5.5 , but never used in an exercise before this one. Tricky!
Metadata
Metadata
Assignees
Labels
No labels