> On Jun 26, 2017, at 10:05 AM, Philippe Hausler <phaus...@apple.com> wrote:
> 
> Data.copyBytes will do that under the hood
> 
> var crc: UInt16 = 0
> let amountCopied = withUnsafeMutablePointer(to: &crc) { data.copyBytes(to: 
> UnsafeMutableBufferPointer(start: $0, count: 1)) }
> if amountCopied == MemoryLayout<UInt16>.size {
>    // we have a full crc
> }
> 
> That will probably do what you want; plus it will allow you to do it from a 
> given range of bytes.

Cool. That'd be a nice API to backport to *BufferPointer too!

-Joe
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to