---
title: "withBytes(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/contiguousbytes/withbytes(_:)"
---

# withBytes(_:)

Calls the given closure with the contents of underlying storage.

## Declaration

```swift
func withBytes<R, E>(_ body: (RawSpan) throws(E) -> R) throws(E) -> R where E : Error
```

## Discussion

Discussion note: Calling withBytes multiple times does not guarantee that the same span will be passed in every time.
