<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/UniqueBox",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s9UniqueBoxV"
  },
  "title" : "UniqueBox"
}
-->

# UniqueBox

A smart pointer type that uniquely owns an instance of `Value` on the heap.

```
@frozen struct UniqueBox<Value> where Value : ~Copyable
```

## Topics

### Initializers

[`init(consuming Value)`](/documentation/Swift/UniqueBox/init(_:))

Initializes a value of this unqiue box with the given initial value.

### Instance Properties

[`var mutableSpan: MutableSpan<Value>`](/documentation/Swift/UniqueBox/mutableSpan)

A mutable span over the single element stored in this box.

[`var span: Span<Value>`](/documentation/Swift/UniqueBox/span)

A span over the single element stored in this box.

[`var value: Value`](/documentation/Swift/UniqueBox/value)

Dereferences the unique box allowing for in-place reads and writes to the
stored `Value`.

### Instance Methods

[`func clone() -> UniqueBox<Value>`](/documentation/Swift/UniqueBox/clone())

Copies the value within the unqiue box and returns it in a new unique
instance.

[`func consume() -> Value`](/documentation/Swift/UniqueBox/consume())

Consumes the unique box and returns the instance of `Value` that was
within the box.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

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)