Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

actix / actix-web Public

Does not live enough error #2812

shishamo asked this question in Q&A Jul 17, 2022 · 1 comment Something went wrong. Quote reply

>'s edit

<> deleted this content .>'s edit Something went wrong. Jul 17, 2022

I have a borrowing compile error.
Do you have any idea of what is going wrong?

use actix_web::web; use serde::Deserialize; use std::str; #[derive(Debug, Deserialize, Clone)] pub struct Params  q: String, > pub fn parse'a, T>(query: &'a str) -> ResultT, std::io::Error> where T: Deserialize'a>,  let params = web::Query::Params>::from_query(query).unwrap(); let base64_buf = base64::decode(&params.q).unwrap(); let to_string = str::from_utf8(&base64_buf).unwrap(); // ERROR => base64_buf does not live enough borrowed value does not live long enough let file_ref: T = serde_json::from_str(to_string).unwrap(); Ok(file_ref) >

Beta Was this translation helpful? Give feedback.

1 You must be logged in to vote

All reactions

It works after changing T: Deserialize, by T: DeserializeOwned, .
Used serde::de::DeserializeOwned