Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Submitted on December 29, 2022 at 02:12 AM

main.rs (Rust)

#[derive(Default, Debug, Clone)]
struct Test {
    vector: Vec<i32>,
}

fn main() {
    const N: usize = 10;
    const DEFAULT: Test = Test { vector: vec![] };
    let mut array: [Test; N] = [DEFAULT; N];

    for x in &mut array {
        for i in 1..100 {
            x.vector.push(i);
        }
    }

    let array_ptr = array.as_mut_ptr();

    for i in (1..N).rev() {
        unsafe {
            array_ptr.add(i).write(array_ptr.add(i - 1).read());
        }
    }

    // unsafe { array_ptr.write(Default::default()); }
    array[0] = Default::default();

    println!("{:?}", array);
}