core::ptr::Shared - Rust
Description: API documentation for the Rust `Shared` struct in crate `core`.
Keywords: rust, rustlang, rust-lang, Shared

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

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

🔬 This is a nightly-only experimental API. (`shared` #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 has shared ownership of the referent. Useful for building abstractions like `Rc<T>` or `Arc<T>`, which internally use raw pointers to manage the memory that they own.

## Methods

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

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

🔬 This is a nightly-only experimental API. (`shared` #27730)

Creates a new `Shared`.

# Safety

`ptr` must be non-null.

## Trait Implementations

### `impl<T: ?Sized> !Send for Shared<T>`
[src]

`Shared` pointers are not `Send` because the data they reference may be aliased.

### `impl<T: ?Sized> !Sync for Shared<T>`
[src]

`Shared` pointers are not `Sync` because the data they reference may be aliased.

### `impl<T: ?Sized> Clone for Shared<T>`
[src]

#### `fn clone(&self) -> Self`

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`
1.0.0

Performs copy-assignment from `source`. Read more

### `impl<T: ?Sized> Copy for Shared<T>`
[src]

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

### `impl<T: ?Sized> Deref for Shared<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 Shared<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`)