I've seen some examples and explanations on the net and I understand what the problem is but I don't now how to solve it ... Lets start with the problem :
--> src/crates/tlb/src/lib.rs:153:25
|
151 | pub fn read<'de, T: Deserialize<'de>>(&mut self, data: String)-> T {
| --- lifetime `'de` defined here
152 |
153 | bincode::deserialize(&(self.obj.translate(data).unwrap())).unwrap()
| ----------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| | |
| | creates a temporary which is freed while still in use
| argument requires that borrow lasts for `'de`
154 |
155 | }
| - temporary value is freed at the end of this statement
What is happening : translate()
method of obj
takes in a String
, processes it and returns Result<Vec<u8>, Err>
Sometimes I want to deserialize
its return back to String sometimes I need it in Vec<u8>
format. my question: What I need to do to make one function return two forms of a result. Or at leas A string for starters
Thank you