I am trying to create Error
enums that implement to_string()
. I have tried to derive(Debug)
for them but it doesn't seem to be enough.
Here is the enum that I am working on:
#[derive(Debug, Clone)]
pub enum InnerError {
InnerErrorWithDescription(String),
}
#[derive(Debug, Clone)]
pub enum OuterError {
OuterErrorWithDescription(String),
}
What I am trying to make is:
// result type <T,InnerErrorWithDescription>
result.map_err(|err| { Error::OuterErrorWithDescription(err.to_string())}) // .to_string() is not available
I could not manage to convert InnerError
enum type to OuterError
.
What should I change to implement it?
I have made an example for writing enum types and their values' here:
But, still I had to specify the type and it's description in match case, are there any more generic implementation?