---
title: "copyBytes(from:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unsafemutablerawbufferpointer/copybytes(from:)-6hg9u"
---

# copyBytes(from:)

Copies from a collection of UInt8 into this buffer’s memory.

## Declaration

```swift
func copyBytes<C>(from source: C) where C : Collection, C.Element == UInt8
```

## Parameters

- `source`: A collection of UInt8 elements. source.count must be less than or equal to this buffer’s count.

## Discussion

Discussion If the first source.count bytes of memory referenced by this buffer are bound to a type T, then T must be a trivial type, the underlying pointer must be properly aligned for accessing T, and source.count must be a multiple of MemoryLayout<T>.stride. After calling copyBytes(from:), the first source.count bytes of memory referenced by this buffer are initialized to raw bytes. If the memory is bound to type T, then it contains values of type T.
