Function std::ptr::copy_memory[src]

pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint)

Copies data from one location to another.

Copies count elements (not bytes) from src to dst. The source and destination may overlap.

copy_memory is semantically equivalent to C's memmove.

Example

Efficiently create a Rust vector from an unsafe buffer:

use std::ptr;
use std::slice;

unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> ~[T] {
    let mut dst = slice::with_capacity(elts);
    dst.set_len(elts);
    ptr::copy_memory(dst.as_mut_ptr(), ptr, elts);
    dst
}