pub unsafe trait VCopy<'a>: VClone<'a> {
    fn vcopy(&'a self) -> VCopier<'a, Self> { ... }
}
Expand description

Support for shallow byte-wise copy of varlen types.

Types that implement this trait can be copied by a bulk copy of the byte buffer at which the object is stored.

Examples

use varlen::prelude::*;

let s1: VBox<Str> = VBox::new(Str::copy("hello"));
let s2: VBox<Str> = VBox::new(s1.vcopy());

Safety

Implementors of this trait must guarantee that this type is safe for bytewise copy. Usually it is sufficient to guarantee that all fields implement VCopy.

Provided methods

Returns an initializer that does a bulk byte copy of self.

Examples
use varlen::prelude::*;

let s1: VBox<Str> = VBox::new(Str::copy("hello"));
let s2: VBox<Str> = VBox::new(s1.vcopy());

Implementors

Strings can be copied with fast memcpy.

Examples

use varlen::prelude::*;
let arr = VBox::new(Str::copy("hello"));
let seq: Seq<Str> = seq![arr.vcopy(), arr.vcopy(), arr.vcopy()];
for a in seq.iter() {
    assert_eq!(&a[..], "hello");
}

Arrays can be copied (fast memcpy) if their elements can.

Examples

use varlen::prelude::*;
let arr = VBox::new(Array::copy(&[1u8, 2, 3]));
let seq: Seq<Array<u8>> = seq![arr.vcopy(), arr.vcopy(), arr.vcopy()];  // Copies the array
for a in seq.iter() {
    assert_eq!(&a[..], &[1, 2, 3]);
}