# 1.0.0[−][src]Function std::intrinsics::copy

    pub unsafe extern "rust-intrinsic" fn copy<T>(
        src: *const T,
        dst: *mut T,
        count: usize
    )

Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source and destination may overlap.

If the source and destination will never overlap, `copy_nonoverlapping` can be used instead.

`copy` is semantically equivalent to C's `memmove`, but with the argument order swapped. Copying takes place as if the bytes were copied from `src` to a temporary array and then copied from the array to `dst`.

# Safety

Behavior is undefined if any of the following conditions are violated:

- `src` must be valid for reads of `count * size_of::<T>()` bytes.

- `dst` must be valid for writes of `count * size_of::<T>()` bytes.

- Both `src` and `dst` must be properly aligned.

Like `read`, `copy` creates a bitwise copy of `T`, regardless of whether `T` is `Copy`. If `T` is not `Copy`, using both the values in the region beginning at `*src` and the region beginning at `*dst` can violate memory safety.

Note that even if the effectively copied size (`count * size_of::<T>()`) is `0`, the pointers must be non-NULL and properly aligned.

# Examples

Efficiently create a Rust vector from an unsafe buffer:

    use std::ptr;

    unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {
        let mut dst = Vec::with_capacity(elts);
        dst.set_len(elts);
        ptr::copy(ptr, dst.as_mut_ptr(), elts);
        dst
    }Run

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse 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`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)