i have the funcion
pub fn make_response<T>(r: &crate::app_logic::Result<T>) -> String
where
T: Serialize,
{
match r
{
Ok(res) => serde_json::to_string(&Response::new(Some(res), &super::ERRORS::OK)).unwrap(),
Err(e) =>
{
serde_json::to_string(&Response::<Option<crate::models::User>>::new(None, e)).unwrap()
}
}
}
which uses Serializible generic T
so as you may see here on the error case i have to use turbofish with the Response
although its just None
. Why is this really necessary?
I am passing there the None
variant which is Simply the part of Option itself and has nothing to do with the generic T
.
I hope I expressed myself clear enough.