# Struct core::ptr::Unique [−] [src]

    pub struct Unique<T: ?Sized> { /* fields omitted */ }

Unstable (`unique` #27730)

: needs an RFC to flesh out design

A wrapper around a raw non-null `*mut T` that indicates that the possessor of this wrapper owns the referent. This in turn implies that the `Unique<T>` is `Send`/`Sync` if `T` is `Send`/`Sync`, unlike a raw `*mut T` (which conveys no particular ownership semantics). It also implies that the referent of the pointer should not be modified without a unique path to the `Unique` reference. Useful for building abstractions like `Vec<T>` or `Box<T>`, which internally use raw pointers to manage the memory that they own.

## Methods

### `impl<T: ?Sized> Unique<T>`
[src]

#### `unsafe fn new(ptr: *mut T) -> Unique<T>`

Unstable (`unique` #27730)

Creates a new `Unique`.

# Safety

`ptr` must be non-null.

#### `unsafe fn get(&self) -> &T`

Unstable (`unique` #27730)

Dereferences the content.

#### `unsafe fn get_mut(&mut self) -> &mut T`

Unstable (`unique` #27730)

Mutably dereferences the content.

## Trait Implementations

### `impl<T: Send + ?Sized> Send for Unique<T>`
[src]

`Unique` pointers are `Send` if `T` is `Send` because the data they reference is unaliased. Note that this aliasing invariant is unenforced by the type system; the abstraction using the `Unique` must enforce it.

### `impl<T: Sync + ?Sized> Sync for Unique<T>`
[src]

`Unique` pointers are `Sync` if `T` is `Sync` because the data they reference is unaliased. Note that this aliasing invariant is unenforced by the type system; the abstraction using the `Unique` must enforce it.

### `impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U>`
[src]

### `impl<T: ?Sized> Deref for Unique<T>`
[src]

#### `type Target = *mut T`

The resulting type after dereferencing

#### `fn deref(&self) -> &*mut T`

The method called to dereference a value

### `impl<T> Pointer for Unique<T>`
[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`

Formats the value using the given formatter.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)