'Rationale behind Swift's BidirectionalCollection extension

It is my understanding that extensions are often used on protocols to provide a default implementation. My question is about a pattern I have observed in the Swift Standard Library's protocol BidirectionalCollection. Consider the code below:

protocol BidirectionalCollection: {
    // other method requirements ...

    func distance(from start: Self.Index, to end: Self.Index) -> Int

    // other method requirements ...
}

followed by

extension BidirectionalCollection {
    // other default implementations ...

    @inlinable public func distance(from start: Self.Index, to end: Self.Index) -> Int

    // other default implementations ...
}

I don't understand two things about this extension:

  1. Why we are able to write the method without a body (which I have always seen in default method implementations), and

  2. What value this specific extension brings. At first glance the only difference just seems the leading @inlinable public. But can't protocol method requirements be prepended with those keywords anyway? What is the use of doing it in the protocol extension?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source