Code RoomString pointer after drop
HardPrep Room Coding #1795

String pointer after drop

Code reviewCode quality & reviewSenior–Staff~30 min

Review this Rust FFI-style helper using raw pointers.

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.

0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1fn make_label() -> *const u8 {
2 let s = String::from("ready");
3 s.as_ptr()
4}
5 
6fn main() {
7 let p = make_label();
8 unsafe {
9 let slice = std::slice::from_raw_parts(p, 5);
10 println!("{:?}", std::str::from_utf8_unchecked(slice));
11 }
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.