|
|
|
|
|
by jdmnd
1547 days ago
|
|
It works for any type that implements the `std::error::Error` trait; which is something you can easily implement for your own types.
If you want your errors to be integers for some reason, you can wrap that type in a zero-sized "newtype" wrapper, and implement `Error` for that. The Stack Overflow answer you linked seems to be claiming that it's simply easier to return strings, but I wouldn't say this is a restriction imposed by the language. |
|
have you ever actually done that? I have, its not easy. Please dont try to hand wave away negatives of the Rust type system.