Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow TCPSockets in a SocketSet without 'static storage lifetime
`TCPSocket` buffers are type `RingBuffer<'a, _>` whilst other socket types have buffers with type `PacketBuffer<'a, 'b, _>`. There is an enum over socket types `pub enum Socket<'a, 'b: 'a>`, which is in turn used by `set::Item` and `SocketSet`. The lifetime `'b` is not required for `TcpSocket`, but the `Into<Socket>` implementation for `TCPSocket` specifies the `'static` lifetime for `'b`. Therefore using `TCPSocket` in a `SocketSet` currently requires the lifetime `'b` for other sockets to be `'static` which is unnecessarily restrictive. This patch fixes this. The lifetime signature of socket specifies `'b: 'a`, that is `'b` outlives `'a`. Instead of `'static`, this is also satisfied by `impl<'a> Into<Socket<'a, 'a>> for TcpSocket<'a>` as `'a` "outlives" `'a` by definition. The example [here](https://gist.github.com/richardeoin/b562e79d0d499e00a8bf4944f00594d9) fails to compile without this patch. Closes: smoltcp-rs#304 Approved by: whitequark
- Loading branch information