Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
base: efdde337b912
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
compare: 1ada3da5aa33
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Aug 15, 2019

  1. 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: #304
    Approved by: whitequark
    richardeoin authored and Homu committed Aug 15, 2019
    Configuration menu
    Copy the full SHA
    1ada3da View commit details
    Browse the repository at this point in the history