1 2 3 4 5 6 7 8 9 10 11 12
use std::mem::ManuallyDrop; /// Returns a Vec with *actual* length. pub fn vec_filled_with<T: Clone>(filler: T, len: usize) -> Vec<T> { let mut out = Vec::with_capacity(len); out.resize(len, filler); out } pub unsafe fn take_manually_drop<T>(slot: &mut ManuallyDrop<T>) -> T { ManuallyDrop::into_inner(std::ptr::read(slot)) }