-
|
Hi people, I have a borrowing compile error. Thank you~ 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) -> Result<T, std::io::Error>
where
T: Deserialize<'a>,
{
let params = web::Query::<Params>::from_query(query).unwrap();
let base64_buf = base64::decode(¶ms.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.
Answered by
shishamo
Jul 17, 2022
Replies: 1 comment
-
|
It works after changing |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
shishamo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works after changing
T: Deserialize<'a>,byT: DeserializeOwned,.Used
serde::de::DeserializeOwned