Borrowed value does not live long enough (as_byte())

Hello, I don’t understand for what my variable does not live long enough. I’ve tried many things but nothing works.

error[E0597]: `PHRASE` does not live long enough
  --> src/
23 |             let content: &[u8] = PHRASE.as_bytes();
   |                                  ^^^^^^ borrowed value does not live long enough
26 |         })
   |         - borrowed value only lives until here
   = note: borrowed value must be valid for the static lifetime...

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.

My Code:

service_fn_ok(|_| {

            let mut PHRASE: String = "Hello World!".to_owned();
            PHRASE.push_str("what do you want");

            let content: &[u8] = PHRASE.as_bytes();

            return Response::new(Body::from(content));

PHRASE is local to you closure, and as such gets deallocated when the closure ends. This would make content a dangling reference, which rust helpfully prevents you from having.

As for solving the problem, you need to return something from the closure which owns PHRASE. You can try the into_bytes method, but I’m not sure Body::from is happy about that.

Return a Boxed value. That allocates on the heap and will be deallocated when the caller is finished with it.

Tank’s you a lot man! You save my passion for the rust!