pub struct CloneFrom<'a, T>(pub &'a [T]);
Expand description

Fills an array by cloning from a source array. Source and destination must have identical length.

Examples

use varlen::prelude::*;

let src = ["hello".to_string(), "world".to_string()];
let arr: [String; 2] = new_array(CloneFrom(&src));
assert_eq!(src, arr);

Panics

Panics if the source and destination have different lengths.

let arr: [String; 1] = new_array(CloneFrom(&src));  // Panics

Tuple Fields

0: &'a [T]

Trait Implementations

Fills the slice. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.