Pressure Scenario: E0597 Lifetime Too Short
Skill Under Test
m01-ownership
User Question
"Why am I getting E0597: borrowed value does not live long enough?"
Code Context
fn get_str() -> &str {
let s = String::from("hello");
&s // E0597
}
Expected Behavior
- Explain stack vs heap lifetime
- Show why returned reference is invalid
- Provide fix options (return owned, 'static, lifetime params)
- Quick reference for lifetime patterns
- Reference to P.MEM.LFT.01, P.MEM.LFT.02 guidelines
Baseline Test (without skill)
Date: [To be filled]
Result:
- Stack/heap lifetime: [PASS/FAIL]
- Invalid reference: [PASS/FAIL]
- Fix options: [PASS/FAIL]
- Quick reference: [PASS/FAIL]
- Guidelines: [PASS/FAIL]
Notes: [To be filled after test]
Post-Skill Test
Date: [To be filled]
Result:
- Stack/heap lifetime: [PASS/FAIL]
- Invalid reference: [PASS/FAIL]
- Fix options: [PASS/FAIL]
- Quick reference: [PASS/FAIL]
- Guidelines: [PASS/FAIL]
Notes: [To be filled after test]
Edge Cases
- "What if I use Box?" → Should explain heap allocation
- "Can I use 'static?" → Should explain when appropriate
- "What about Cow?" → Should suggest for flexible ownership