[Foundation] DataProtocol: Reimplement firstRange(of:in:)/lastRange(of:in:) to fix SR-10689.
[Foundation] DataProtocol: Reimplement firstRange(of:in:)/lastRange(of:in:) to fix SR-10689.

Cherry-pick from https://github.com/apple/swift-corelibs-foundation/pull/2499

apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation