<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/UnsafeMutableRawBufferPointer/init(rebasing:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sw8rebasingSws5SliceVySwG_tcfc"
  },
  "title" : "init(rebasing:)"
}
-->

# init(rebasing:)

Creates a raw buffer over the same memory as the given raw buffer slice,
with the indices rebased to zero.

```
init(rebasing slice: Slice<UnsafeMutableRawBufferPointer>)
```

## Parameters

`slice`

The raw buffer slice to rebase.

## Discussion

The new buffer represents the same region of memory as the slice, but its
indices start at zero instead of at the beginning of the slice in the
original buffer. The following code creates `slice`, a slice covering
part of an existing buffer instance, then rebases it into a new `rebased`
buffer.

```
let slice = buffer[n...]
let rebased = UnsafeRawBufferPointer(rebasing: slice)
```

After this code has executed, the following are true:

- `rebased.startIndex == 0`
- `rebased[0] == slice[n]`
- `rebased[0] == buffer[n]`
- `rebased.count == slice.count`

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)