Allow TCPSockets in a SocketSet without 'static storage lifetime #304
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TCPSocket
buffers are typeRingBuffer<'a, _>
whilst other socket types have buffers with typePacketBuffer<'a, 'b, _>
.There is an enum over socket types
pub enum Socket<'a, 'b: 'a>
, which is in turn used byset::Item
andSocketSet
. The lifetime'b
is not required forTcpSocket
, but theInto<Socket>
implementation forTCPSocket
specifies the'static
lifetime for'b
.Therefore using
TCPSocket
in aSocketSet
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 byimpl<'a> Into<Socket<'a, 'a>> for TcpSocket<'a>
as'a
"outlives"'a
by definition.The example here fails to compile without this patch (tested on
rustc 1.38.0-nightly (07e0c3651 2019-07-16)
)