memcpy() comparison: C, Rust, and D

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 1 09:22:43 PST 2017


Walter Bright <newshound2 at digitalmars.com> wrote:
> I'm not very familiar with Rust. Can you post what a Rust declaration for memcpy 
> would look like with all the guarantees?

You wouldn't use memcpy but just assign the slices. Assignment is always
just memcpy in Rust because of move-semantics:

a[m1..n1] = b[m2..n2];

It will panic if sizes don't match.

But if you still wanted a memcpy it would probably look like this:

fn memcpy<'a, T>(dest: &'a mut [T], src: &[T]) -> &'a mut [T]


More information about the Digitalmars-d mailing list