Code Room
Vibe codingMediumvc-g340
Subject Ai code reviewLevel Mid–Senior~16 minCommon in Networking & APIs interviewsIndustries Telecom, Software development

Question

An AI generated this Rust code to serialize a port number and sequence value into a fixed network header before sending. It compiles and round-trips fine in the same process. Explain why a peer on a different machine misreads the header, the trigger, and the fix.

rust
fn write_header(seq: u32, port: u16) -> [u8; 6] {    let mut hdr = [0u8; 6];    let seq_bytes = seq.to_ne_bytes();    let port_bytes = port.to_ne_bytes();    hdr[0..4].copy_from_slice(&seq_bytes);    hdr[4..6].copy_from_slice(&port_bytes);    hdr}
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.