How to set &str that from enum A to struct B?

Hi guys.

I defined an error enum:

pub enum MyError<'a> {
    MissingField(&'a str),
}

and defined an struct:

pub struct SimpleMessageError<'a>(pub &'a str);

then, I implemented From trait for SimpleMessageError:

impl<'a: 'b, 'b> From<MyError<'b>> for SimpleMessageError<'a> {
    fn from(e: MyError<'b>) -> Self {
        match e {
            MyError::MissingField(f) => SimpleMessageError(f),
        }
    }
}

but rustc said:

error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
   --> src/err.rs:102:15
    |
102 |         match e {
    |               ^
    |
note: first, the lifetime cannot outlive the lifetime 'b as defined on the impl at 100:14...
   --> src/err.rs:100:14
    |
100 | impl<'a: 'b, 'b> From<MyError<'b>> for SimpleMessageError<'a> {
    |              ^^
    = note: ...so that the types are compatible:
            expected err::MyError<'_>
               found err::MyError<'b>
note: but, the lifetime must be valid for the lifetime 'a as defined on the impl at 100:6...
   --> src/err.rs:100:6
    |
100 | impl<'a: 'b, 'b> From<MyError<'b>> for SimpleMessageError<'a> {
    |      ^^
    = note: ...so that the expression is assignable:
            expected err::SimpleMessageError<'a>
               found err::SimpleMessageError<'_>

although rustc gave some explaination, but I still can not figure out how to solve this problem?

or maybe this is a program design issue?

Once I changed lifetime 'a and 'b both to 'static, compile error was gone.

You messed up the order of lifetimes. Not 'a depends on 'b, but the other way around. So this should be

impl<'a, 'b: 'a> From<MyError<'b>> for SimpleMessageError<'a> {

or simplified

impl<'a> From<MyError<'a>> for SimpleMessageError<'a> {

Thank you hellow
simplified workaround is more clear than 2 lifetime params