Here's a more elegant one that additionally shows why it's important to expose the base
s of the standard library's adapter types:
extension BidirectionalCollection {
func dropLast(while predicate: (Element) throws -> Bool) rethrows -> Self.SubSequence {
let head = try self.reversed().drop(while: predicate)
return self[head.endIndex.base..<head.startIndex.base]
}
}