Struct varlen::array_init::CloneFrom
source · [−]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
sourceimpl<'a, T: Clone> ArrayInitializer<T> for CloneFrom<'a, T>
impl<'a, T: Clone> ArrayInitializer<T> for CloneFrom<'a, T>
sourcefn initialize(self, dst: &mut [MaybeUninit<T>])
fn initialize(self, dst: &mut [MaybeUninit<T>])
Fills the slice. Read more
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for CloneFrom<'a, T> where
T: RefUnwindSafe,
impl<'a, T> Send for CloneFrom<'a, T> where
T: Sync,
impl<'a, T> Sync for CloneFrom<'a, T> where
T: Sync,
impl<'a, T> Unpin for CloneFrom<'a, T>
impl<'a, T> UnwindSafe for CloneFrom<'a, T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more