Code Room
Code reviewHardcr-g372
Subject LifetimesLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Rust parser that keeps a pointer to a slice of its own buffer to avoid re-scanning.

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
struct Parser {    buf: String,    cursor: *const u8, // points into buf} impl Parser {    fn new(s: String) -> Parser {        let cursor = s.as_ptr();        Parser { buf: s, cursor }    }    fn first(&self) -> u8 {        unsafe { *self.cursor }    }} let p = Parser::new("hello".into());let p2 = p;          // movelet _ = p2.first();  // deref cursor
Run or narrate your approach, then ask the coach.