#slice #deprecated #place #copying #copy #safe-wrapper #byte

deprecated copy_in_place

[deprecated] a safe wrapper around ptr::copy for efficient copying within slices

5 releases

Uses old Rust 2015

0.2.2 Nov 29, 2022
0.2.1 Aug 15, 2019
0.2.0 Sep 17, 2018
0.1.1 Sep 4, 2018
0.1.0 Aug 26, 2018

#32 in #copying


Used in buf-ref-reader

MIT license

6KB
56 lines

copy_in_place

RepoDocsCrate

This crate provides a single function, a safe wrapper around ptr::copy for efficient copying within slices.

DEPRECATED: As of Rust 1.37, the standard library provides the equivalent copy_within method on slices. This crate is deprecated, and it won't receive any further updates or fixes.

Examples

Copying four bytes within a slice:

let mut bytes = *b"Hello, World!";

copy_in_place(&mut bytes, 1..5, 8);

assert_eq!(&bytes, b"Hello, Wello!");

lib.rs:

RepoDocsCrate

This crate provides a single function, a safe wrapper around ptr::copy for efficient copying within slices.

DEPRECATED: As of Rust 1.37, the standard library provides the equivalent copy_within method on slices. This crate is deprecated, and it won't receive any further updates or fixes.

Examples

Copying four bytes within a slice:

let mut bytes = *b"Hello, World!";

copy_in_place(&mut bytes, 1..5, 8);

assert_eq!(&bytes, b"Hello, Wello!");

No runtime deps