Code Room
Code reviewHardcr-g386
Subject Uninitialized memoryLevel Senior–Staff~28 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Rust code building a fixed config struct via MaybeUninit to skip a Default.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewrust
use std::mem::MaybeUninit;struct Config { host: String, port: u16, retries: u32 } fn build(host: String, port: u16) -> Config {    let mut c = MaybeUninit::<Config>::uninit();    let p = c.as_mut_ptr();    unsafe {        (*p).host = host;            // (1)        (*p).port = port;        c.assume_init()              // retries never set    }}
Run or narrate your approach, then ask the coach.