---
title: RawSpan
framework: swift
role: symbol
role_heading: Structure
path: swift/rawspan
---

# RawSpan

RawSpan represents a contiguous region of memory which contains initialized bytes.

## Declaration

```swift
@frozen struct RawSpan
```

## Overview

Overview A RawSpan instance is a non-owning, non-escaping view into memory. When a RawSpan is created, it inherits the lifetime of the container owning the contiguous memory, ensuring temporal safety and avoiding use-after-free errors. Operations on RawSpan are bounds-checked, ensuring spatial safety and avoiding buffer overflow errors.

## Topics

### Initializers

- [init()](swift/rawspan/init().md)

### Instance Properties

- [byteCount](swift/rawspan/bytecount.md)
- [byteOffsets](swift/rawspan/byteoffsets.md)
- [isEmpty](swift/rawspan/isempty.md)

### Instance Methods

- [byteOffsets(of:)](swift/rawspan/byteoffsets(of:).md)
- [extracting(_:)](swift/rawspan/extracting(_:)-2imhy.md)
- [extracting(_:)](swift/rawspan/extracting(_:)-3elv4.md)
- [extracting(_:)](swift/rawspan/extracting(_:)-8oy0e.md)
- [extracting(droppingFirst:)](swift/rawspan/extracting(droppingfirst:).md)
- [extracting(droppingLast:)](swift/rawspan/extracting(droppinglast:).md)
- [extracting(first:)](swift/rawspan/extracting(first:).md)
- [extracting(last:)](swift/rawspan/extracting(last:).md)
- [extracting(unchecked:)](swift/rawspan/extracting(unchecked:)-2hjqs.md)
- [extracting(unchecked:)](swift/rawspan/extracting(unchecked:)-527ri.md)
- [isIdentical(to:)](swift/rawspan/isidentical(to:).md)
- [isTriviallyIdentical(to:)](swift/rawspan/istriviallyidentical(to:).md)
- [unsafeLoad(fromByteOffset:as:)](swift/rawspan/unsafeload(frombyteoffset:as:).md)
- [unsafeLoad(fromUncheckedByteOffset:as:)](swift/rawspan/unsafeload(fromuncheckedbyteoffset:as:).md)
- [unsafeLoadUnaligned(fromByteOffset:as:)](swift/rawspan/unsafeloadunaligned(frombyteoffset:as:).md)
- [unsafeLoadUnaligned(fromUncheckedByteOffset:as:)](swift/rawspan/unsafeloadunaligned(fromuncheckedbyteoffset:as:).md)
- [withBytes(_:)](swift/rawspan/withbytes(_:).md)
- [withUnsafeBytes(_:)](swift/rawspan/withunsafebytes(_:).md)

### Default Implementations

- [BorrowingSequence Implementations](swift/rawspan/borrowingsequence-implementations.md)

## Relationships

### Conforms To

- [BitwiseCopyable](swift/bitwisecopyable.md)
- [BorrowingSequence](swift/borrowingsequence.md)
- [ContiguousBytes](foundation/contiguousbytes.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Safe Memory Access

- [Span](swift/span.md)
- [OutputSpan](swift/outputspan.md)
- [OutputRawSpan](swift/outputrawspan.md)
- [UTF8Span](swift/utf8span.md)
- [MutableSpan](swift/mutablespan.md)
- [MutableRawSpan](swift/mutablerawspan.md)
