Compiler borrow issue for match block

I am getting a weird error involving the "field.text().await.unwrap_or("".to_string())" for something line giving me this error:
emporary value dropped while borrowed
creates a temporary value which is freed while still in userustcClick for full compiler diagnostic
something.rs(55, 105): temporary value is freed at the end of this statement
something.rs(55, 31): argument requires that borrow lasts for 'static

pub async fn add_something(mut fields: Multipart) -> Result<String, (StatusCode, String)>{
  let mut works = "".to_string();
  let mut something = "".to_string();
  while let Some(field) = fields.next_field().await.map_err(|err| (StatusCode::BAD_REQUEST, err.to_string())).unwrap() {
    match &name[..] {
        "works" => works = field.text().await.unwrap_or("".to_string()),
        "something" => something = field.text().await.unwrap_or("".to_string()).split(',').collect::<Vec<_>>(),
        _ => print!("nothing")
    }
}

Also asked this on r/rust, but there neckbeard mods removed it in .005 seconds. Lovely people lol

First, click Click for full compiler diagnostic and read the actual error. If you're still not sure what to do, post that in a code block.

Also post your actual code. Where did name come from? Why are you trying to assign a Vec to a String?

This is the code, I just renamed some variables.

error[E0716]: temporary value dropped while borrowed
   |
   | "something" => something = field.text().await.unwrap_or("".to_string()).split(',').collect::<Vec<_>>(),
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------
   |                            |                                          |
   |                            |                                          temporary value is freed at the end of this statement
   |                            creates a temporary value which is freed while still in use
   |                            argument requires that borrow lasts for `'static`

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.