I'm having error[E0495]: cannot infer an appropraite lifetime due to conflicting requirements. Can someone please help me understand what's exactly wrong here or even how to fix it? I'm unable to comprehend the error.
I previously used just self
and moved to &self
now, since then I get this error.
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> /mnt/windows/code/oss/reqrs/src/lib.rs:122:51
|
122 | TcpStream::connect(&socket_addr).and_then(move |stream| {
| ___________________________________________________^
123 | | tokio::io::write_all(stream, dst_vec)
124 | | .and_then(|(stream, _)| {
125 | | let initial_vec: Vec<u8> = vec![0; INITIAL_BUF_SIZE];
... |
197 | | .map_err(|e| io::Error::new(io::ErrorKind::Other, e))
198 | | })
| |_________^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 108:5...
--> /mnt/windows/code/oss/reqrs/src/lib.rs:108:5
|
108 | / fn begin_read(
109 | | &self,
110 | | key: (Arc<String>, u16),
111 | | dst_vec: Vec<u8>,
... |
198 | | })
199 | | }
| |_____^
= note: ...so that the types are compatible:
expected &Client
found &Client
= note: but, the lifetime must be valid for the static lifetime...
note: ...so that return value is valid for the call
--> /mnt/windows/code/oss/reqrs/src/lib.rs:112:10
|
112 | ) -> impl Future<Item = ClientResponse, Error = io::Error> + Send {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is my code:
https://github.com/nihiluis/reqx/blob/master/src/lib.rs#L122
Many thanks