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

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

Examples

use varlen::prelude::*;
let arr: [u16; 5] = new_array(CopyFrom(&[3, 1, 4, 1, 5]));
assert_eq!(arr, [3, 1, 4, 1, 5]);

Panics

Panics if the source and destination arrays have different length.

use varlen::prelude::*;
let arr: [u16; 6] = new_array(CopyFrom(&[3, 1, 4, 1, 5]));  // Panic
use varlen::prelude::*;
let arr: [u16; 4] = new_array(CopyFrom(&[3, 1, 4, 1, 5]));  // Panic

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.