replaceSubrange(_:with:)
Replaces a region of bytes in the data with new bytes from a collection.
Declaration
mutating func replaceSubrange<ByteCollection>(_ subrange: Range<Data.Index>, with newElements: ByteCollection) where ByteCollection : Collection, ByteCollection.Element == UInt8Parameters
- subrange:
The range in the data to replace.
- newElements:
The replacement bytes.
Discussion
This will resize the data if required, to fit the entire contents of newElements.
Precondition: The bounds of subrange must be valid indices of the collection.