How to initialize struct obj

error[E0381]: assign to part of possibly-uninitialized variable: `compress_buffer`
  --> src/
81 |                 compress_buffer.batch_nonces = nonces;
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `compress_buffer`
let compress_buffer: CompressBuffer;
            unsafe {
                compress_buffer.batch_nonces = nonces;
                compress_buffer.final_buffer = Vec::from_raw_parts(
                    pointer_final as *mut u8,
                compress_buffer.compute_buffer =
                    Vec::from_raw_parts(pointer_compute as *mut u8, buffer_size, buffer_size);
                compress_buffer.know_buffer =
                    Vec::from_raw_parts(pointer_known as *mut u8, buffer_size, buffer_size);

is that we can't initial object with uninitalized ?

You must initialize the entire variable to a value before you can modify its fields.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.